Problem: You have a set of dominoes. Each domino is a rectangular tile with a line dividing its face into two square ends. Can you put all dominoes in a line one by one from left to right so that any two dominoes touched with the sides that had the same number of points? You can rotate the dominoes, changing the left and the right side (domino "1-4" turns into "4-1").

Input

The first line contains number n (1 ≤ n ≤ 100). Next n lines contains the dominoes. Each of these lines contains two numbers — the number of points (spots) on the left and the right half, correspondingly. The numbers of points (spots) are non-negative integers from 0 to 6.

Output

Print "No solution", if it is impossible to arrange the dominoes in the required manner. If the solution exists, then describe any way to arrange the dominoes. You put the dominoes from left to right. In each of n lines print the index of the domino to put in the corresponding position and then, after a space, character "+" (if you don't need to turn the domino) or "–" (if you need to turn it).

Examples

Input

5
1 2
2 4
2 4
6 4
2 1


Output

2 -
1 -
5 -
3 +
4 -

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
bool f[7];
int n, du[7], st, en, e[7][7];
queue<int> sav[7][7];
vector<int> ans, tmp, t[2];
void walk(int now) {
  tmp.push_back(now);
  if (tmp.size() > 1 && now == en) return;
  du[now]--;
  for (int i = 0; i <= 6; i++)
    if (e[now][i] && du[i]) {
      e[now][i]--;
      e[i][now]--;
      du[i]--;
      walk(i);
      break;
    }
}
void add() {
  t[0].clear();
  t[1].clear();
  int flag = 0;
  for (int i = 0; i < ans.size(); i++)
    if (!flag && ans[i] == st)
      flag = 1;
    else
      t[flag].push_back(ans[i]);
  tmp.clear();
  walk(st);
  ans.clear();
  for (int i = 0; i < t[0].size(); i++)
    ans.push_back(t[0][i]), f[t[0][i]] = true;
  for (int i = 0; i < tmp.size(); i++) ans.push_back(tmp[i]), f[tmp[i]] = true;
  for (int i = 0; i < t[1].size(); i++)
    ans.push_back(t[1][i]), f[t[1][i]] = true;
}
int main() {
  while (scanf("%d", &n) == 1) {
    memset(e, 0, sizeof(e));
    memset(f, 0, sizeof(f));
    for (int i = 0; i <= 6; i++) du[i] = 0;
    for (int i = 0; i <= 6; i++)
      for (int j = 0; j <= 6; j++)
        while (sav[i][j].size()) sav[i][j].pop();
    for (int i = 1; i <= n; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      e[x][y]++, e[y][x]++;
      du[x]++;
      du[y]++;
      sav[x][y].push(i);
    }
    tmp.clear();
    ans.clear();
    for (int i = 0; i <= 6; i++) {
      if (du[i] % 2) tmp.push_back(i);
      if (du[i] > 1) st = en = i;
    }
    if (tmp.size() > 2) {
      printf("No solution\n");
      continue;
    } else {
      if (tmp.size() == 2) st = tmp[0], en = tmp[1];
      add();
      while (1) {
        bool flag = false;
        for (int i = 0; i <= 6 && !flag; i++)
          if (du[i] && f[i]) flag = true, st = en = i, add();
        if (!flag) break;
      }
      if (ans.size() != n + 1) {
        printf("No solution\n");
        continue;
      }
      for (int i = 1; i < ans.size(); i++) {
        int x = ans[i - 1], y = ans[i];
        if (sav[x][y].size()) {
          printf("%d +\n", sav[x][y].front());
          sav[x][y].pop();
        } else {
          printf("%d -\n", sav[y][x].front());
          sav[y][x].pop();
        }
      }
    }
  }
  return 0;
}