#define IO_FILES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>

#define PROBLEM_NAME "revolving-lasers"

using namespace std;

int    const MAX_S =  360;
int    const ADD   =    2;
double const EPS   = 1E-9;

struct laser
{
	int x, y, a;
};

struct point
{
	double x, y;
	point (void) {}
	point (double nx, double ny): x (nx), y (ny) {}
};

struct coord
{
	int x, y;
	coord (void) {x = -1; y = -1;}
	coord (int nx, int ny): x (nx), y (ny) {}
	bool operator == (coord const & other) const
	{
		return x == other.x && y == other.y;
	}
	bool operator != (coord const & other) const
	{
		return !(*this == other);
	}
};

coord const NA = coord ();
char const code [3] [3] = {{'1', '4', '7'}, {'2', '5', '8'}, {'3', '6', '9'}};

double vp (point a, point b, point c)
{
	return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);
}

double sp (point a, point b, point c)
{
	return (b.x - a.x) * (c.x - a.x) + (b.y - a.y) * (c.y - a.y);
}

bool possible (point a, point b, point c, point u, point v)
{
	if ((sp (a, b, u) < -EPS) && (sp (a, b, v) < -EPS) &&
	    (sp (a, c, u) < -EPS) && (sp (a, c, v) < -EPS))
	{
		return true;
	}
	double x = vp (a, b, u);
	double y = vp (a, c, v);
	return (abs (y) > EPS) && (x * y > EPS);
}

string solve (int n, laser * p)
{
	int xlo = 0;
	int xhi = 0;
	int ylo = 0;
	int yhi = 0;
	for (int i = 0; i < n; i++)
	{
		xlo = min (xlo, p[i].x - ADD);
		xhi = max (xhi, p[i].x + ADD);
		ylo = min (ylo, p[i].y - ADD);
		yhi = max (yhi, p[i].y + ADD);
	}
	int xsize = xhi - xlo + 1;
	int ysize = yhi - ylo + 1;

	point q [n];
	for (int i = 0; i < n; i++)
	{
		q[i] = point (p[i].x - xlo, p[i].y - ylo);
	}

	point r [MAX_S + 1] [n];
	for (int s = 0; s <= MAX_S; s++)
	{
		for (int i = 0; i < n; i++)
		{
			double angle = 0.25 + p[i].a * s * 1.0 / MAX_S;
			angle *= 2.0 * M_PI;
			r[s][i] = point (p[i].x - xlo + cos (angle),
			                 p[i].y - ylo + sin (angle));
		}
	}

	coord f [MAX_S + 1] [xsize] [ysize];
	f[0][0 - xlo][0 - ylo] = coord (0 - xlo, 0 - ylo);
	for (int s = 0; s <= MAX_S; s++)
	{
		for (int x = 0; x < xsize; x++)
		for (int y = 0; y < ysize; y++)
		if (f[s][x][y] != NA)
		{
			point u = point (x, y);
			for (int dx = -1; dx <= +1; dx++)
			for (int dy = -1; dy <= +1; dy++)
			{
				int nx = x + dx;
				int ny = y + dy;
				if (nx < 0 || nx >= xsize ||
				    ny < 0 || ny >= ysize)
				{
					goto end_dy_loop;
				}
				for (int i = 0; i < n; i++)
				{
					if ((nx == p[i].x) && (ny == p[i].y))
					{
						goto end_dy_loop;
					}
				}
				for (int i = 0; i < n; i++)
				{
					point v = point (nx, ny);
					if (!possible (q[i], r[s][i],
					               r[s + 1][i],
					               u, v))
					{
						goto end_dy_loop;
					}
				}
				f[s + 1][nx][ny] = coord (x, y);
				end_dy_loop: ;
			}
		}
	}

	if (f[MAX_S][0 - xlo][0 - ylo] == NA)
	{
		return string ("None");
	}

	string res;
	coord u = coord (0 - xlo, 0 - ylo);
	for (int s = MAX_S; s > 0; s--)
	{
		coord v = f[s][u.x][u.y];
		res += code[u.x - v.x + 1][u.y - v.y + 1];
		u = v;
	}
	reverse (res.begin (), res.end ());
	return res;
}

int main (void)
{
#ifdef IO_FILES
	freopen (PROBLEM_NAME ".in",  "rt", stdin);
	freopen (PROBLEM_NAME ".out", "wt", stdout);
#endif

	int n;
	while (scanf (" %d", &n) > 0)
	{
		laser p [n];
		for (int i = 0; i < n; i++)
		{
			scanf (" %d %d %d", &p[i].x, &p[i].y, &p[i].a);
		}
		printf ("%s\n", solve (n, p).c_str ());
		fflush (stdout);
	}
	return 0;
}
