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 N = 2010;
int n, m1, m2;
int tp1[N], tp2[N];
struct Graph {
  int in[N];
  bitset<N> e[N];
  void floyd() {
    for (int k = 2; k <= 2 * n + 1; k++)
      for (int i = 2; i <= 2 * n + 1; i++)
        if (e[i][k]) e[i] |= e[k];
  }
  void dfs(int u) {
    if (in[u]) return;
    in[u] = 1, in[u ^ 1] = -1;
    for (int v = 2; v <= 2 * n + 1; v++)
      if (e[u][v]) dfs(v);
  }
  void solve() {
    for (int i = 1; i <= n; i++) {
      if (!in[2 * i]) {
        if (e[2 * i][2 * i + 1])
          dfs(2 * i + 1);
        else
          dfs(2 * i);
      }
      printf("%d ", in[2 * i] == 1);
    }
  }
} f, g;
int main() {
  scanf("%d%d%d", &n, &m1, &m2);
  for (int i = 1; i <= m1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u = (u > 0) ? 2 * u : -2 * u + 1;
    v = (v > 0) ? 2 * v : -2 * v + 1;
    f.e[u ^ 1][v] = f.e[v ^ 1][u] = 1;
  }
  for (int i = 1; i <= m2; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u = (u > 0) ? 2 * u : -2 * u + 1;
    v = (v > 0) ? 2 * v : -2 * v + 1;
    g.e[u ^ 1][v] = g.e[v ^ 1][u] = 1;
  }
  f.floyd(), g.floyd();
  bool pd1 = 0, pd2 = 0;
  for (int i = 1; i <= n; i++) {
    if (f.e[2 * i][2 * i + 1] && f.e[2 * i + 1][2 * i]) pd1 = 1;
    if (g.e[2 * i][2 * i + 1] && g.e[2 * i + 1][2 * i]) pd2 = 1;
  }
  if (pd1 && pd2) {
    puts("SIMILAR");
    return 0;
  }
  if (pd1) {
    g.solve();
    return 0;
  }
  if (pd2) {
    f.solve();
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (f.e[2 * i][2 * i + 1])
      tp1[i] = -1;
    else if (f.e[2 * i + 1][2 * i])
      tp1[i] = 1;
    else
      tp1[i] = 0;
    if (g.e[2 * i][2 * i + 1])
      tp2[i] = -1;
    else if (g.e[2 * i + 1][2 * i])
      tp2[i] = 1;
    else
      tp2[i] = 0;
    if (tp1[i] == tp2[i]) continue;
    if ((tp1[i] == 1 && tp2[i] == -1) || (tp1[i] == -1 && tp2[i] == 1)) {
      f.solve();
      return 0;
    } else if (tp1[i] == 0) {
      if (tp2[i] == 1) {
        f.dfs(2 * i + 1), f.solve();
        return 0;
      } else {
        f.dfs(2 * i), f.solve();
        return 0;
      }
    } else if (tp2[i] == 0) {
      if (tp1[i] == 1) {
        g.dfs(2 * i + 1), g.solve();
        return 0;
      } else {
        g.dfs(2 * i), g.solve();
        return 0;
      }
    }
  }
  for (int i = 2; i <= 2 * n + 1; i++)
    for (int j = 2; j <= 2 * n + 1; j++) {
      if (i == j || !(f.e[i][j] ^ g.e[i][j])) continue;
      if (f.e[i][j]) {
        g.dfs(i), g.dfs(j ^ 1), g.solve();
        return 0;
      }
      if (g.e[i][j]) {
        f.dfs(i), f.dfs(j ^ 1), f.solve();
        return 0;
      }
    }
  puts("SIMILAR");
}
