#include <set>
#include "algotester.h"
using namespace std;
const int MAXN = 1e5;
vector<int> g[MAXN];
set<int> adj[MAXN];
bool used[MAXN];
void dfs(int v)
{
used[v] = true;
for (auto to : g[v])
if (!used[to])
dfs(to);
}
int main()
{
auto reader = initValidator();
int n = reader.readInt(0, MAXN, "n");
reader.readEndl();
for (int i = 0; i < n; i++)
{
int a = reader.readInt(0, n, "a");
reader.readSpace();
int b = reader.readInt(0, n, "b");
reader.readEndl();
a--, b--;
g[a].push_back(b);
g[b].push_back(a);
adj[a].insert(b);
adj[b].insert(a);
}
reader.readEof();
int cnt = 0;
for (int i = 0; i < n; i++) cnt += adj[i].size();
check(cnt == 2 * n, "multiedges");
dfs(0);
for (int i = 0; i < n; i++)
check(used[i], "not a single component");
return 0;
}