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 = 1010, maxm = maxn * maxn;
typedef bitset<(maxn << 1) + 5> BitSet;
pair<int, int> edA[maxm + 5], edB[maxm + 5];
BitSet A[(maxn << 1) + 5], B[(maxn << 1) + 5];
BitSet odd;
int n;
int Get(int x) {
  if (x < 0) {
    x = -x, --x;
    return x << 1;
  }
  --x;
  return x << 1 | 1;
}
inline bool Check(const BitSet &x) { return (((x & odd) >> 1) & x).none(); }
BitSet ban;
int ans[maxn + 5];
inline void find(BitSet *f) {
  for (int _n(n), i(0); i < _n; i++) {
    if (ban[i << 1] || (f[i << 1] & ban).any() || !Check(f[i << 1])) {
      ans[i] = 1;
    } else {
      ans[i] = 0;
    }
    ban[i << 1 | (!ans[i])] = 1;
  }
}
int main() {
  const string similar = "SIMILAR";
  int m1, m2;
  cin >> n >> m1 >> m2;
  for (int _n(m1), i(0); i < _n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u = Get(u);
    v = Get(v);
    A[u ^ 1][v] = 1;
    A[v ^ 1][u] = 1;
    edA[i] = make_pair(u, v);
  }
  for (int _n(m2), i(0); i < _n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u = Get(u);
    v = Get(v);
    B[u ^ 1][v] = 1;
    B[v ^ 1][u] = 1;
    edB[i] = make_pair(u, v);
  }
  for (int _n(n), i(0); i < _n; i++) odd[i << 1 | 1] = 1;
  for (int _n(n << 1), i(0); i < _n; i++) A[i][i] = B[i][i] = 1;
  for (int _n(n << 1), i(0); i < _n; i++)
    for (int _n(n << 1), j(0); j < _n; j++)
      if (A[j][i]) A[j] |= A[i];
  for (int _n(n << 1), i(0); i < _n; i++)
    for (int _n(n << 1), j(0); j < _n; j++)
      if (B[j][i]) B[j] |= B[i];
  bool canA = 1, canB = 1;
  for (int _n(n), i(0); i < _n; i++)
    if (A[i << 1][i << 1 | 1] && A[i << 1 | 1][i << 1]) {
      canA = 0;
      break;
    }
  for (int _n(n), i(0); i < _n; i++)
    if (B[i << 1][i << 1 | 1] && B[i << 1 | 1][i << 1]) {
      canB = 0;
      break;
    }
  if (!canA && !canB) {
    cout << similar << endl;
  } else if (canA ^ canB) {
    if (canA) {
      find(A);
    } else {
      find(B);
    }
    for (int _n(n), i(0); i < _n; i++) printf("%d ", ans[i]);
    printf("\n");
  } else {
    for (int _n(m1), i(0); i < _n; i++) {
      int u = edA[i].first ^ 1, v = edA[i].second ^ 1;
      if (Check(B[u] | B[v])) {
        ban[u ^ 1] = ban[v ^ 1] = 1;
        find(B);
        for (int _n(n), i(0); i < _n; i++) printf("%d ", ans[i]);
        printf("\n");
        return 0;
      }
    }
    for (int _n(m2), i(0); i < _n; i++) {
      int u = edB[i].first ^ 1, v = edB[i].second ^ 1;
      if (Check(A[u] | A[v])) {
        ban[u ^ 1] = ban[v ^ 1] = 1;
        find(A);
        for (int _n(n), i(0); i < _n; i++) printf("%d ", ans[i]);
        printf("\n");
        return 0;
      }
    }
    cout << similar << endl;
  }
  return 0;
}
