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>
int N, M1, M2;
inline int inv(int x) { return x <= N ? x + N : x - N; }
struct graph {
  std::bitset<2001> G[2001];
  bool no_solution;
  int f[2001];
  void Start(int p) {
    if (~f[p]) return;
    f[p] = 1;
    f[inv(p)] = 0;
    for (int i = 1; i <= N + N; i++)
      if (G[p][i]) Start(i);
  }
  void floyd() {
    for (int i = 1; i <= N + N; i++) G[i].set(i);
    for (int i = 1; i <= N + N; i++)
      for (int j = 1; j <= N + N; j++)
        if (G[j][i]) G[j] |= G[i];
    for (int i = 1; i <= N; i++)
      if (G[i][i + N] && G[i + N][i]) {
        no_solution = true;
        return;
      }
    for (int i = 1; i <= N + N; i++) f[i] = -1;
    for (int i = 1; i <= N; i++)
      if (G[i][i + N]) Start(i + N);
    for (int i = 1; i <= N; i++)
      if (G[i + N][i]) Start(i);
  }
  void print() {
    for (int i = 1; i <= N + N; i++)
      if (!~f[i]) Start(i);
    for (int i = 1; i <= N; i++) printf("%d%c", f[i], " \n"[i == N]);
    exit(0);
  }
} G1, G2;
void Solve(graph &A, graph &B) {
  if (A.no_solution) return;
  if (B.no_solution) A.print();
  for (int i = 1; i <= N + N; i++)
    if (A.f[i] && !B.f[i]) {
      A.Start(i);
      A.print();
    }
  for (int i = 1; i <= N + N; i++)
    for (int j = 1; j <= N + N; j++)
      if (!~A.f[i] && !~A.f[j] && !A.G[i][j] && B.G[i][j]) {
        A.Start(i);
        A.Start(inv(j));
        A.print();
      }
}
int main() {
  scanf("%d%d%d", &N, &M1, &M2);
  for (int i = 1, x, y; i <= M1; i++) {
    scanf("%d%d", &x, &y);
    if (x < 0) x = N - x;
    if (y < 0) y = N - y;
    G1.G[inv(x)].set(y);
    G1.G[inv(y)].set(x);
  }
  for (int i = 1, x, y; i <= M2; i++) {
    scanf("%d%d", &x, &y);
    if (x < 0) x = N - x;
    if (y < 0) y = N - y;
    G2.G[inv(x)].set(y);
    G2.G[inv(y)].set(x);
  }
  G1.floyd();
  G2.floyd();
  Solve(G1, G2);
  Solve(G2, G1);
  puts("SIMILAR");
  return 0;
}
