#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100 + 10;

int G[MAXN][MAXN], col[MAXN], N;

bool dfs(int u) {
    if (u == N + 1) return true;
    for (int c = 1; c <= 4; ++ c) {
        bool flag = true;
        for (int v = 1; v < u && flag; ++ v) {
            if (G[u][v] && col[v] == c) flag = false;
        }
        if (flag && (col[u] = c, dfs(u + 1))) return true;
    }
    return false;
}

int main() {
    scanf("%d", &N);
    memset(col, 0, sizeof(col));
    memset(G, 0, sizeof(G));
    for (int a, b; scanf("%d-%d", &a, &b) == 2; ) G[a][b] = G[b][a] = 1;
    dfs(1);
    for (int i = 1; i <= N; ++ i) printf("%d %d\n", i, col[i]);
    return 0;
}
