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 long double PI = acos(-1.0);
const int MAXN = 1001;
int n, m1, m2, m;
struct edg {
  bitset<MAXN> a;
  bitset<MAXN> b;
  bool good;
};
pair<int, int> e1[MAXN * MAXN];
pair<int, int> e2[MAXN * MAXN];
edg a[4 * MAXN];
vector<int> e[4 * MAXN];
vector<int> eo[4 * MAXN];
bool w[4 * MAXN];
vector<int> tout;
inline int rekt(int x) {
  if (x > 0)
    return x - 1;
  else
    return 2 * n + x;
}
void dfs(int v) {
  if (w[v]) return;
  w[v] = true;
  for (int i = 0; i < e[v].size(); i++) {
    dfs(e[v][i]);
  }
  tout.push_back(v);
}
vector<int> cc;
void dfs2(int v) {
  if (w[v]) return;
  w[v] = true;
  cc.push_back(v);
  for (int i = 0; i < eo[v].size(); i++) {
    dfs2(eo[v][i]);
  }
}
bool good(edg& a, edg& b) {
  return (a.good && b.good && ((a.b ^ b.b) & a.a & b.a).none());
}
bool merg(edg& a, edg& b) {
  if (!a.good || !b.good) return false;
  if (((a.b ^ b.b) & a.a & b.a).any()) return false;
  a.a |= b.a;
  a.b |= (b.a & b.b);
  return true;
}
void solve() {
  memset(w, 0, sizeof(w));
  tout.clear();
  for (int i = 0; i < 2 * n; i++) {
    e[i].clear();
    eo[i].clear();
  }
  for (int i = 0; i < m1; i++) {
    e[m - e1[i].first].push_back(e1[i].second);
    e[m - e1[i].second].push_back(e1[i].first);
    eo[e1[i].second].push_back(m - e1[i].first);
    eo[e1[i].first].push_back(m - e1[i].second);
  }
  for (int i = 0; i < 2 * n; i++) dfs(i);
  reverse(tout.begin(), tout.end());
  for (int i = 0; i < 2 * n; i++) {
    a[i].a.reset();
    a[i].b.reset();
    a[i].good = true;
    a[i].a[min(i, m - i)] = 1, a[i].b[min(i, m - i)] = i / n;
  }
  for (int i = tout.size() - 1; i >= 0; i--) {
    int v = tout[i];
    for (int j = 0; j < e[v].size(); j++) {
      if (!merg(a[v], a[e[v][j]])) a[v].good = false;
    }
  }
  memset(w, 0, sizeof(w));
  for (int i = 0; i < tout.size(); i++) {
    cc.clear();
    int v = tout[i];
    if (w[v]) continue;
    dfs2(v);
    for (int j = 1; j < cc.size(); j++) {
      if (!merg(a[v], a[cc[j]])) a[v].good = false;
    }
    for (int j = 1; j < cc.size(); j++) {
      if (!merg(a[cc[j]], a[v])) a[cc[j]].good = false;
    }
  }
  memset(w, 0, sizeof(w));
  for (int i = 0; i < m2; i++) {
    if (good(a[m - e2[i].first], a[m - e2[i].second])) {
      edg cur;
      cur.a.reset();
      cur.b.reset();
      merg(cur, a[m - e2[i].first]);
      merg(cur, a[m - e2[i].second]);
      for (int j = 0; j < 2 * n; j++) {
        merg(cur, a[j]);
      }
      for (int j = 0; j < n; j++) {
        cout << 1 - cur.b[j] << " ";
      }
      cout << endl;
      exit(0);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m1, &m2);
  m = 2 * n - 1;
  for (int i = 0; i < m1; i++) {
    scanf("%d%d", &e1[i].first, &e1[i].second);
    e1[i] = make_pair(rekt(e1[i].first), rekt(e1[i].second));
  }
  for (int i = 0; i < m2; i++) {
    scanf("%d%d", &e2[i].first, &e2[i].second);
    e2[i] = make_pair(rekt(e2[i].first), rekt(e2[i].second));
  }
  solve();
  swap(m1, m2);
  for (int i = 0; i < max(m1, m2); i++) swap(e1[i], e2[i]);
  solve();
  cout << "SIMILAR" << endl;
  return 0;
}
