#include <iostream>
#include <cstring>
#include <string>
#include <sstream>
using namespace std;
int mat[100][100];
int mark[100];
int pos[4][2] = {{-1, 0}, {0, 1}, {0, -1}, {1, 0}};
int part, n, x, y;
bool b;
string str;
void dfs (int a, int b)
{
mat[a][b] = -1;
for (int i = 0; i < 4; i++)
{
int t1 = a + pos[i][0];
int t2 = b + pos[i][1];
if (t1 >= 0 && t1 < n && t2 >= 0 && t2 < n && mat[t1][t2] == part)
dfs (t1, t2);
}
}
int main ()
{
while (cin >> n && n != 0)
{
for (int i = 0; i < n; i++)
memset (mat[i], 0, sizeof mat[i]);
memset (mark, 0, sizeof mark);
getline (cin, str);
for (int i = 1; i < n; i++)
{
getline (cin, str);
stringstream ss (str);
while (ss >> x >> y)
mat[x-1][y-1] = i;
}
bool b = true;
for (int i = 0; b && i < n; i++)
for (int j = 0; j < n; j++)
if (mat[i][j] >= 0)
{
part = mat[i][j];
if (mark[part])
{
b = false;
break;
}
else
{
mark[part]= 1;
dfs (i, j);
}
}
if (b)
cout << "good" << endl;
else
cout << "wrong" << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHNzdHJlYW0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1hdFsxMDBdWzEwMF07CmludCBtYXJrWzEwMF07CmludCBwb3NbNF1bMl0gPSB7ey0xLCAwfSwgezAsIDF9LCB7MCwgLTF9LCB7MSwgMH19OwppbnQgcGFydCwgbiwgeCwgeTsKYm9vbCBiOwpzdHJpbmcgc3RyOwoKdm9pZCBkZnMgKGludCBhLCBpbnQgYikKewoJbWF0W2FdW2JdID0gLTE7Cglmb3IgKGludCBpID0gMDsgaSA8IDQ7IGkrKykKCXsKCQlpbnQgdDEgPSBhICsgcG9zW2ldWzBdOwoJCWludCB0MiA9IGIgKyBwb3NbaV1bMV07CgkJaWYgKHQxID49IDAgJiYgdDE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