#include <cstdio>
#include <cstring>
#include <algorithm>
char m[1024][1025];
int a[1024];
bool check(int n)
{
    if ('1' == m[a[1]][a[0]])
        return false;
    for (int i = 1; i < n; ++ i)
        if ('0' == m[a[i]][a[i + n]])
            std :: swap(a[i], a[i + n]);
    int cnt = 1;
    for (int i = 1; i < n; ++ i)
    {
        if ('1' == m[a[0]][a[i]])
            ++ cnt;
        else
        {
            bool flag = false;
            for (int j = 1; j < n; ++ j)
                if ('1' == m[a[j]][a[i]])
                {
                    flag = true;
                    break;
                }
            if (false == flag)
                return false;
        }
    }
    return cnt * 2 >= n;
}
bool use[1024];
int b[1024];
void arrange(int n)
{
    memset(use, false, 2 * n);
    for (int i = 0; i < n * 2; ++ i)
        b[i] = a[i];
    int size = 1;
    for (int i = 1; i < n * 2; ++ i)
        if (!use[i] && '0' == m[0][b[i]])
            for (int j = 1; j < n * 2; ++ j)
                if (i != j && !use[j] && '1' == m[0][b[j]] && '0' == m[b[i]][b[j]])
                {
                    a[size] = b[j];
                    a[n + size ++] = b[i];
                    use[i] = use[j] = true;
                    break;
                }
    for (int i = 1; i < n * 2; ++ i)
        if (!use[i] && '0' == m[0][b[i]])
            for (int j = 1; j < n * 2; ++ j)
                if (i != j && !use[j] && '0' == m[0][b[j]])
                {
                    a[size] = b[j];
                    a[n + size ++ ] = b[i];
                    use[i] = use[j] = true;
                    break;
                }
    for (int i = 1; i < n * 2; ++ i)
        if (!use[i] && '0' == m[0][b[i]])
            for (int j = 1; j < n * 2; ++ j)
                if (i != j && !use[j] && '1' == m[0][b[j]])
                {
                    a[size] = b[j];
                    a[n + size ++] = b[i];
                    use[i] = use[j] = true;
                    break;
                }
    for (int i = 1; i < n * 2; ++ i)
        if (!use[i] && '1' == m[0][b[i]])
            for (int j = 1; j < n * 2; ++ j)
                if (i != j && !use[j] && '1' == m[0][b[j]])
                {
                    a[size] = b[j];
                    a[n + size ++] = b[i];
                    use[i] = use[j] = true;
                    break;
                }
    for (int i = 1; i < n * 2; ++ i)
        if (!use[i])
        {
            a[0] = 0;
            a[n] = b[i];
            break;
        }
}
void solve(int n)
{
    if (1 == n)
        return ;
    n /= 2;
    check(n);
    arrange(n);
    while (!check(n))
        puts("FUCK");
    for (int i = 0; i < n; ++ i)
        printf("%d %d\n", a[i] + 1, a[i + n] + 1);
    solve(n);
}
int main()
{
    int n;
    while (scanf("%d", &n) != EOF)
    {
        for (int i = 0; i < n; ++ i)
            for (int j = 0; j < n; ++ j)
                scanf(" %c", &m[i][j]);
        for (int i = 0; i < n; ++ i)
            a[i] = i;
        solve(n);
    }
}