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 = 1005;
int n;
struct two_sat {
  int m, ok;
  int fixed[maxn << 1];
  bitset<maxn << 1> g[maxn << 1];
  void get(int x) {
    fixed[x] = 1, fixed[(x > n ? (x - n) : (x + n))] = 0;
    for (int i = 1; i <= 2 * n; i++)
      if (g[x][i] && fixed[i] == -1) get(i);
  }
  void build() {
    for (int i = 1; i <= 2 * n; i++) g[i].reset(), g[i][i] = 1, fixed[i] = -1;
    for (int i = 1; i <= m; i++) {
      int x, y;
      scanf("%d%d", &x, &y), x = x > 0 ? x : (-x > n ? (-x - n) : (-x + n)),
                             y = y > 0 ? y : (-y > n ? (-y - n) : (-y + n));
      g[(x > n ? (x - n) : (x + n))][y] = 1,
                                g[(y > n ? (y - n) : (y + n))][x] = 1;
    }
    for (int k = 1; k <= 2 * n; k++)
      for (int i = 1; i <= 2 * n; i++)
        if (g[i][k]) g[i] |= g[k];
    for (int i = 1; i <= n; i++)
      if (g[i][n + i] && g[n + i][i]) {
        ok = 0;
        return;
      }
    ok = 1;
    for (int i = 1; i <= n; i++) {
      if (fixed[i] == -1 && fixed[n + i] == -1 && g[i][n + i]) get(n + i);
      if (fixed[i] == -1 && fixed[n + i] == -1 && g[n + i][i]) get(i);
    }
  }
  void solve() {
    for (int i = 1; i <= 2 * n; i++)
      if (fixed[i] == -1) get(i);
    for (int i = 1; i <= n; i++) printf("%d%c", fixed[i], i == n ? '\n' : ' ');
  }
} A, B;
int main() {
  scanf("%d%d%d", &n, &A.m, &B.m), A.build(), B.build();
  if (A.ok == 0 && B.ok == 0) {
    puts("SIMILAR");
    return 0;
  }
  if (A.ok == 0 || B.ok == 0) {
    if (A.ok) A.solve();
    if (B.ok) B.solve();
    return 0;
  }
  for (int i = 1; i <= 2 * n; i++) {
    if (A.fixed[i] != -1 && B.fixed[i] != -1 && A.fixed[i] != B.fixed[i]) {
      A.solve();
      return 0;
    }
    if ((A.fixed[i] == -1) + (B.fixed[i] == -1) == 1) {
      if (A.fixed[i] == -1)
        A.get(B.fixed[i] == 0 ? i : (i > n ? (i - n) : (i + n))), A.solve();
      if (B.fixed[i] == -1)
        B.get(A.fixed[i] == 0 ? i : (i > n ? (i - n) : (i + n))), B.solve();
      return 0;
    }
  }
  for (int i = 1; i <= 2 * n; i++)
    for (int j = 1; j <= 2 * n; j++) {
      if (A.g[i][j] && B.g[i][j] == 0 && B.fixed[i] == -1 && B.fixed[i] == -1) {
        B.get(i), B.get((j > n ? (j - n) : (j + n))), B.solve();
        return 0;
      }
      if (B.g[i][j] && A.g[i][j] == 0 && A.fixed[i] == -1 && A.fixed[j] == -1) {
        A.get(i), A.get((j > n ? (j - n) : (j + n))), A.solve();
        return 0;
      }
    }
  puts("SIMILAR");
  return 0;
}
