Little Artem is a very smart programmer. He knows many different difficult algorithms. Recently he has mastered in 2-SAT one.

In computer science, 2-satisfiability (abbreviated as 2-SAT) is the special case of the problem of determining whether a conjunction (logical AND) of disjunctions (logical OR) have a solution, in which all disjunctions consist of no more than two arguments (variables). For the purpose of this problem we consider only 2-SAT formulas where each disjunction consists of exactly two arguments.

Consider the following 2-SAT problem as an example: <image>. Note that there might be negations in 2-SAT formula (like for x1 and for x4).

Artem now tries to solve as many problems with 2-SAT as possible. He found a very interesting one, which he can not solve yet. Of course, he asks you to help him. 

The problem is: given two 2-SAT formulas f and g, determine whether their sets of possible solutions are the same. Otherwise, find any variables assignment x such that f(x) ≠ g(x). 

Input

The first line of the input contains three integers n, m1 and m2 (1 ≤ n ≤ 1000, 1 ≤ m1, m2 ≤ n2) — the number of variables, the number of disjunctions in the first formula and the number of disjunctions in the second formula, respectively.

Next m1 lines contains the description of 2-SAT formula f. The description consists of exactly m1 pairs of integers xi ( - n ≤ xi ≤ n, xi ≠ 0) each on separate line, where xi > 0 corresponds to the variable without negation, while xi < 0 corresponds to the variable with negation. Each pair gives a single disjunction. Next m2 lines contains formula g in the similar format.

Output

If both formulas share the same set of solutions, output a single word "SIMILAR" (without quotes). Otherwise output exactly n integers xi (<image>) — any set of values x such that f(x) ≠ g(x).

Examples

Input

2 1 1
1 2
1 2


Output

SIMILAR


Input

2 1 1
1 2
1 -2


Output

0 0 

Note

First sample has two equal formulas, so they are similar by definition.

In second sample if we compute first function with x1 = 0 and x2 = 0 we get the result 0, because <image>. But the second formula is 1, because <image>.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2018;
struct TwoSAT {
  bitset<MAXN> G[MAXN];
  void AddOr(int u, int v) {
    bool f1 = 0, f2 = 0;
    if (u < 0) u = -u, f1 = 1;
    if (v < 0) v = -v, f2 = 1;
    u--;
    v--;
    G[(u * 2) ^ f1][(v * 2 + 1) ^ f2] = 1;
    G[(v * 2) ^ f2][(u * 2 + 1) ^ f1] = 1;
  }
  void Floyd(int n) {
    for (int k = 0; k < 2 * n; k++)
      for (int i = 0; i < 2 * n; i++)
        if (G[i][k]) G[i] |= G[k];
    for (int i = 0; i < 2 * n; i++)
      if (G[i][i ^ 1])
        for (int j = 0; j < 2 * n; j++) G[i][j] = 1, G[j][i ^ 1] = 1;
    for (int k = 0; k < 2 * n; k++)
      for (int i = 0; i < 2 * n; i++)
        if (G[i][k]) G[i] |= G[k];
  }
  void dfs(int u, int n, int ans[]) {
    if (ans[u] != -1) return;
    ans[u] = 1;
    ans[u ^ 1] = 0;
    for (int i = 0; i < 2 * n; i++)
      if (G[u][i]) dfs(i, n, ans);
  }
  void solve(int ans[], int u, int v, int n) {
    dfs(u, n, ans);
    dfs(v ^ 1, n, ans);
    for (int i = 0; i < n * 2; i++)
      if (ans[i] == -1) dfs(i, n, ans);
  }
} F, G;
int n, m1, m2;
int ans[MAXN];
int main() {
  scanf("%d%d%d", &n, &m1, &m2);
  for (int i = 1, u, v; i <= m1; i++) {
    scanf("%d%d", &u, &v);
    F.AddOr(u, v);
  }
  F.Floyd(n);
  for (int i = 1, u, v; i <= m2; i++) {
    scanf("%d%d", &u, &v);
    G.AddOr(u, v);
  }
  G.Floyd(n);
  for (int i = 0; i < n * 2; i++)
    for (int j = 0; j < n * 2; j++)
      if (i != j && (i ^ 1) != j && F.G[i][j] != G.G[i][j]) {
        memset(ans, -1, sizeof ans);
        if (F.G[i][j])
          G.solve(ans, i, j, n);
        else
          F.solve(ans, i, j, n);
        for (int k = 0; k < n; k++) printf("%d ", ans[k * 2 + 1]);
        puts("");
        return 0;
      }
  puts("SIMILAR");
  return 0;
}
