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 = 2005;
int n, m[2];
bitset<maxN> all[maxN];
bitset<maxN> rev[maxN];
bool a[2][maxN][maxN];
bool has[2][maxN][maxN];
int transform(int x) {
  if (x > 0)
    return 2 * (x - 1);
  else
    return (((-x) - 1) * 2) + 1;
}
bool bad[maxN];
bool used[maxN];
bool can[maxN][maxN];
int t;
void go(int v) {
  used[v] = true;
  for (int i = 0; i < t; i++) {
    if (can[v][i] && !used[i]) {
      used[i] = true;
      go(i);
    }
  }
}
bool nbad[maxN];
void lastDfs(int v) {
  nbad[v] = true;
  for (int j = 0; j < t; j++) {
    if (can[v][j] && !nbad[j]) {
      lastDfs(j);
    }
  }
}
void ok(int a, int b) {
  memset(used, 0, sizeof used);
  go(a);
  go(b);
  for (int i = 0; i < t; i++) {
    if (used[i] || used[i ^ 1]) continue;
    if (bad[i]) continue;
    bool ff = false;
    for (int j = 0; j < t; j++) {
      if (can[i][j] && used[j ^ 1]) ff = true;
    }
    if (!ff) {
      go(i);
    }
  }
  for (int i = 0; i < t; i++) {
    if (used[i]) lastDfs(i);
  }
  for (int i = 0; i < t; i++) {
    if (nbad[i] && nbad[i ^ 1]) assert(false);
    if (!used[i] && !used[i ^ 1]) assert(false);
  }
  for (int i = 0; i < n; i++) {
    assert(used[2 * i] ^ used[2 * i + 1]);
    if (used[2 * i])
      cout << 1 << " ";
    else
      cout << 0 << " ";
  }
  exit(0);
}
void dfs(int v) {
  used[v] = true;
  for (int i = 0; i < t; i++) {
    if (!can[i][v]) continue;
    if (used[i]) continue;
    bad[i] = true;
    dfs(i);
  }
}
void solve() {
  t = 2 * n;
  for (int i = 0; i < t; i++) {
    all[i] &= 0;
    all[i][i] = true;
    a[0][i][i] = true;
    for (int j = 0; j < t; j++) {
      if (!a[0][i][j]) continue;
      all[i][j] = true;
    }
  }
  for (int k = 0; k < t; k++) {
    for (int i = 0; i < t; i++) {
      if (!a[0][i][k]) continue;
      all[i] |= all[k];
    }
  }
  memset(bad, 0, sizeof bad);
  memset(used, 0, sizeof used);
  memset(can, 0, sizeof can);
  for (int i = 0; i < t; i++) {
    for (int j = 0; j < t; j++) {
      if (all[i][j]) can[i][j] = true;
      if (all[i][j] && all[i][j ^ 1]) bad[i] = true;
    }
  }
  for (int i = 0; i < t; i++) {
    rev[i] &= 0;
    for (int j = 0; j < t; j++) {
      rev[i][j] = all[i][j ^ 1];
    }
  }
  for (int i = 0; i < t; i++) {
    if (!used[i] && bad[i]) dfs(i);
  }
  for (int i = 0; i < t; i++) {
    for (int j = 0; j < t; j++) {
      if (!has[1][i][j]) continue;
      if (bad[i] || bad[j]) continue;
      if (((rev[i] & all[j]).count()) > 0) continue;
      ok(i, j);
    }
  }
  for (int i = 0; i < t; i++) {
    for (int j = 0; j < t; j++) {
      swap(a[1][i][j], a[0][i][j]);
      swap(has[1][i][j], has[0][i][j]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cin >> n >> m[0] >> m[1];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < m[i]; j++) {
      int x, y;
      cin >> x >> y;
      x = transform(x);
      y = transform(y);
      a[i][y ^ 1][x] = true;
      a[i][x ^ 1][y] = true;
      has[i][x ^ 1][y ^ 1] = true;
    }
  }
  for (int i = 0; i < 2; i++) {
    solve();
  }
  cout << "SIMILAR";
}
