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;
int n, m1, m2, ans[2002];
bitset<2002> a[2002], b[2002];
void A(int x) {
  ans[x] = 1, ans[x ^ 1] = 2;
  for (int i = 2; i <= n; i++)
    if (a[x][i] && !ans[i]) A(i);
}
void B(int x) {
  ans[x] = 1, ans[x ^ 1] = 2;
  for (int i = 2; i <= n; i++)
    if (b[x][i] && !ans[i]) B(i);
}
int main() {
  scanf("%d%d%d", &n, &m1, &m2);
  for (int i = 1; i <= m1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x < 0)
      x = -2 * x + 1;
    else
      x = x * 2;
    if (y < 0)
      y = -2 * y + 1;
    else
      y = y * 2;
    a[x ^ 1].set(y), a[y ^ 1].set(x);
  }
  for (int i = 1; i <= m2; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x < 0)
      x = -2 * x + 1;
    else
      x = x * 2;
    if (y < 0)
      y = -2 * y + 1;
    else
      y = y * 2;
    b[x ^ 1].set(y), b[y ^ 1].set(x);
  }
  n = n + n + 1;
  for (int i = 2; i <= n; i++) a[i].set(i), b[i].set(i);
  for (int i = 2; i <= n; i++) {
    for (int j = 2; j <= n; j++) {
      if (a[j][i]) a[j] |= a[i];
      if (b[j][i]) b[j] |= b[i];
    }
  }
  for (int i = 2; i <= n; i++) {
    if (a[i][i ^ 1]) {
      for (int j = 2; j <= n; j++) a[i].set(j), a[j].set(i ^ 1);
    }
    if (b[i][i ^ 1]) {
      for (int j = 2; j <= n; j++) b[i].set(j), b[j].set(i ^ 1);
    }
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 2; j <= n; j++) {
      if (a[j][i]) a[j] |= a[i];
      if (b[j][i]) b[j] |= b[i];
    }
  }
  for (int i = 2; i <= n; i++) {
    if (a[i] == b[i]) continue;
    for (int j = 2; j <= n; j++) {
      if (a[i][j] == b[i][j]) continue;
      if (a[i][j]) {
        j ^= 1;
        B(i);
        if (!ans[j]) B(j);
        for (int k = 2; k <= n; k++) {
          if (!ans[k]) B(k);
        }
        for (int k = 2; k <= n; k += 2) {
          if (ans[k] == 1)
            printf("1 ");
          else
            printf("0 ");
        }
        return 0;
      }
      if (b[i][j]) {
        j ^= 1;
        A(i);
        if (!ans[j]) A(j);
        for (int k = 2; k <= n; k++) {
          if (!ans[k]) A(k);
        }
        for (int k = 2; k <= n; k += 2) {
          if (ans[k] == 1)
            printf("1 ");
          else
            printf("0 ");
        }
        return 0;
      }
    }
  }
  puts("SIMILAR");
  return 0;
}
