#include typedef struct tree { struct tree *p; } tree; typedef struct list { int v; struct list *n; } list; tree *get_root (tree *t) { if (t == NULL | t->p == NULL) { return t; } t->p = get_root(t->p); return t->p; } void func (int v, int tmp_d, list **e, int *d) { list *l = e[v]; if (d[v] > 0) { return; } d[v] = tmp_d; while (l != NULL) { func(l->v, tmp_d+1, e, d); l = l->n; } return; } int main () { int n = 0; int a[200000] = {}; int b[200000] = {}; int res = 0; int ans[200000] = {}; int rt = 0; tree t[200000] = {}; list pool[399998] = {}; int used = 0; list *e[200000] = {}; int d[200000] = {}; res = scanf("%d", &n); for (int i = 0; i < n; i++) { tree *rt1 = NULL; tree *rt2 = NULL; res = scanf("%d", a+i); res = scanf("%d", b+i); a[i]--; b[i]--; rt1 = get_root(t+a[i]); rt2 = get_root(t+b[i]); if (rt1 == rt2) { rt = a[i]; ans[i] = 1; } else { rt2->p = rt1; pool[used].v = b[i]; pool[used].n = e[a[i]]; e[a[i]] = pool+used; used++; pool[used].v = a[i]; pool[used].n = e[b[i]]; e[b[i]] = pool+used; used++; } } func(rt, 1, e, d); for (int i = 0; i < n; i++) { if (ans[i] <= 0 && d[a[i]] < d[b[i]]) { ans[i] = 2; } else if (ans[i] <= 0) { ans[i] = 1; } } for (int i = 0; i < n; i++) { if (ans[i] == 1) { printf("->\n"); } else { printf("<-\n"); } } return 0; }