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 = 2048;
int n;
int R(int x) { return x ^ 1; }
void SIM() {
  cout << "SIMILAR" << endl;
  exit(0);
}
bitset<maxn> a1[maxn], a2[maxn];
int s1[maxn], s2[maxn];
void NONSIM(int s[]) {
  for (int i = 0; i < (int)(n); ++i) {
    printf("%d ", s[i] ^ 1);
  }
  printf("\n");
  exit(0);
}
void readf(int m, bitset<maxn> a[]) {
  for (int i = 0; i < (int)(m); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    {
      bool add = x < 0;
      if (x < 0) x = -x;
      --x;
      x = x * 2 + add;
    }
    {
      bool add = y < 0;
      if (y < 0) y = -y;
      --y;
      y = y * 2 + add;
    }
    a[R(x)][y] = 1;
    a[R(y)][x] = 1;
  }
  for (int i = 0; i < (int)(n * 2); ++i) {
    a[i][i] = 1;
  }
}
void scan() {
  int m1, m2;
  scanf("%d%d%d", &n, &m1, &m2);
  readf(m1, a1);
  readf(m2, a2);
}
void closure(bitset<maxn> a[]) {
  for (int k = 0; k < (int)(n * 2); ++k) {
    for (int i = 0; i < (int)(n * 2); ++i)
      if (a[i][k]) {
        a[i] |= a[k];
      }
  }
}
void take(bitset<maxn> a[], int s[], int x) {
  assert(s[x / 2] == -1);
  s[x / 2] = x & 1;
  for (int i = 0; i < (int)(n * 2); ++i)
    if (s[i / 2] == -1 && a[x][i]) {
      take(a, s, i);
    }
  a[x].reset();
  a[x ^ 1].reset();
  for (int i = 0; i < (int)(n * 2); ++i) {
    a[i][x] = a[i][x ^ 1] = 0;
  }
}
bool reduct(bitset<maxn> a[], int s[]) {
  for (int i = 0; i < n * 2; i += 2) {
    if (a[i][i ^ 1] && a[i ^ 1][i]) {
      return false;
    }
  }
  for (int i = 0; i < n * 2; i += 2) {
    if (a[i][i ^ 1] && a[i ^ 1][i]) {
      return false;
    }
    if (a[i][i ^ 1])
      take(a, s, i ^ 1);
    else if (a[i ^ 1][i])
      take(a, s, i);
  }
  return true;
}
void solve_full(bitset<maxn> a[], int s[]) {
  for (int i = 0; i < (int)(n * 2); ++i)
    if (s[i / 2] == -1) {
      take(a, s, i);
    }
}
void solve() {
  scan();
  memset(s1, -1, sizeof s1);
  memset(s2, -1, sizeof s2);
  closure(a1);
  closure(a2);
  bool res1 = reduct(a1, s1);
  bool res2 = reduct(a2, s2);
  if (!res1 && !res2) {
    SIM();
  } else if (res1 != res2) {
    if (res1) {
      solve_full(a1, s1);
      NONSIM(s1);
    } else {
      solve_full(a2, s2);
      NONSIM(s2);
    }
  }
  for (int i = 0; i < (int)(n); ++i)
    if (s1[i] != -1 && s2[i] != -1 && s1[i] != s2[i]) {
      solve_full(a1, s1);
      NONSIM(s1);
    }
  for (int i = 0; i < (int)(n); ++i)
    if (s1[i] != s2[i]) {
      if (s1[i] == -1) {
        take(a1, s1, i * 2 + !s2[i]);
        solve_full(a1, s1);
        NONSIM(s1);
      } else {
        take(a2, s2, i * 2 + !s1[i]);
        solve_full(a2, s2);
        NONSIM(s2);
      }
    }
  for (int i = 0; i < (int)(n * 2); ++i)
    for (int j = 0; j < (int)(n * 2); ++j)
      if (s1[i / 2] == -1 && s1[j / 2] == -1) {
        if (a1[i][j] != a2[i][j]) {
          if (a1[i][j]) {
            take(a2, s2, i);
            if (s2[j / 2] == -1) take(a2, s2, j ^ 1);
            solve_full(a2, s2);
            NONSIM(s2);
          } else {
            take(a1, s1, i);
            if (s1[j / 2] == -1) take(a1, s1, j ^ 1);
            solve_full(a1, s1);
            NONSIM(s1);
          }
        }
      }
  SIM();
}
int main() {
  solve();
  return 0;
}
