/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com)
 */

#include <vector>
#include <iostream>
#include <cstdio>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back

typedef long long ll;

const int N = 1e5;
int n, a, b, u[N], color[N];
vector<int> c[N], ss, cycle;

void dfs( int v, int pr = -1 ) {
	u[v] = 1, ss.pb(v);
	for (int x : c[v])
		if (!u[x])
			dfs(x, v);
		else if (x != pr && u[x] == 1 && !cycle.size()) {
			for (auto it = ss.rbegin(); *it != x; it++)
				cycle.push_back(*it);
			cycle.push_back(x);
		}
	u[v] = 2, ss.pop_back();
}

void calc( int v ) {
	u[v] = 1;
	for (int x : c[v])
		if (u[x] != 1)
			color[x] = (!color[v] ? 1 : 0), calc(x);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	forn(i, n) {
		cin >> a >> b, a--, b--;
		c[a].pb(b), c[b].pb(a);
	}
	dfs(0);
	forn(i, cycle.size())
		color[cycle[i]] = i & 1, u[cycle[i]] = 1;
	if (cycle.size() & 1)
		color[cycle[0]] = 2;
	for (int x : cycle)
		calc(x);
	forn(i, n)
		cout << color[i] + 1 << " ";
	return 0;
}