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>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const int N = 2000 + 5;
bitset<N> graph[2][N];
bitset<N> invg[2][N];
int n, m[2];
int F(int x) {
  if (x < 0)
    return ((-x - 1) * 2) ^ 1;
  else
    return (x - 1) * 2;
}
int mark[N];
int u;
int res[2][N];
bool solvefor(int U) {
  u = U;
  for (int k = 0; k < 2 * n; ++k) {
    for (int i = 0; i < (int)(2 * n); ++i) {
      if (graph[u][i][k]) graph[u][i] |= graph[u][k];
    }
  }
  for (int i = 0; i < (int)(2 * n); ++i)
    for (int j = 0; j < (int)(2 * n); ++j) invg[u][i][j] = graph[u][j][i];
  for (int i = 0; i < (int)(2 * n); ++i)
    if (graph[u][i][i ^ 1] && graph[u][i ^ 1][i]) return false;
  for (int i = 0; i < (int)(2 * n); ++i) {
    if (res[u][i] || res[u][i ^ 1]) continue;
    if (!graph[u][i][i ^ 1]) {
      for (int j = 0; j < (int)(2 * n); ++j)
        if (graph[u][i][j]) {
          res[u][j] = 1;
          res[u][j ^ 1] = 0;
        }
    }
  }
  return true;
}
bitset<N> M[2][N];
void printing(int u) {
  for (int i = 0; i < 2 * n; i += 2) {
    if (res[u][i])
      printf("1 ");
    else
      printf("0 ");
  }
  puts("");
}
void solve() {
  scanf("%d%d%d", &n, &m[0], &m[1]);
  for (int e = 0; e < (int)(2); ++e) {
    for (int i = 0; i < (int)(2 * n); ++i) graph[e][i][i] = 1;
    for (int i = 1; i <= (int)(m[e]); ++i) {
      int u, v;
      scanf("%d%d", &u, &v);
      u = F(u);
      v = F(v);
      graph[e][u ^ 1][v] = 1;
      graph[e][v ^ 1][u] = 1;
    }
  }
  bool ok1 = solvefor(0);
  bool ok2 = solvefor(1);
  if (ok1 != ok2) {
    if (ok1) {
      printing(0);
    } else {
      printing(1);
    }
    return;
  }
  if (!ok1 && !ok2) {
    puts("SIMILAR");
    return;
  }
  for (int i = 0; i < (int)(2 * n); ++i) {
    if (graph[0][i][i ^ 1] != graph[1][i][i ^ 1]) {
      if (!graph[0][i][i ^ 1]) {
        if (res[0][i ^ 1]) {
          for (int j = 0; j < (int)(2 * n); ++j) {
            if (graph[0][i][j]) {
              res[0][j] = 1;
              res[0][j ^ 1] = 0;
            }
          }
        }
        printing(0);
        return;
      } else {
        if (res[1][i ^ 1]) {
          for (int j = 0; j < (int)(2 * n); ++j) {
            if (graph[1][i][j]) {
              res[1][j] = 1;
              res[1][j ^ 1] = 0;
            }
          }
        }
        printing(1);
        return;
      }
    }
  }
  for (int u = 0; u < (int)(2); ++u) {
    for (int i = 0; i < (int)(2 * n); ++i) {
      for (int j = 0; j < (int)(2 * n); ++j) {
        if (invg[u][i][j]) M[u][j] |= invg[u][i ^ 1];
      }
    }
  }
  for (int i = 0; i < (int)(2 * n); ++i) {
    for (int j = 0; j < (int)(2 * n); ++j) {
      if (M[0][i][j] != M[1][i][j]) {
        if (!M[0][i][j]) {
          for (int v = 0; v < (int)(2 * n); ++v) {
            if (graph[0][i][v]) {
              res[0][v] = 1;
              res[0][v ^ 1] = 0;
            }
            if (graph[0][j][v]) {
              res[0][v] = 1;
              res[0][v ^ 1] = 0;
            }
          }
          printing(0);
          return;
        } else {
          for (int v = 0; v < (int)(2 * n); ++v) {
            if (graph[1][i][v]) {
              res[1][v] = 1;
              res[1][v ^ 1] = 0;
            }
            if (graph[1][j][v]) {
              res[1][v] = 1;
              res[1][v ^ 1] = 0;
            }
          }
          printing(1);
          return;
        }
      }
    }
  }
  puts("SIMILAR");
}
void testgen() {
  FILE* f = fopen("input.txt", "w");
  fclose(f);
}
int main() {
  cout << fixed;
  cout.precision(13);
  cerr << fixed;
  cerr.precision(3);
  solve();
  return 0;
}
