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;
struct edge {
  int x, y, id;
  bool rev;
  edge(int _x = 0, int _y = 0, int _id = 0, bool _rev = false) {
    x = _x, y = _y, id = _id, rev = _rev;
  }
};
int n;
int mat[128][128];
int deg[128];
vector<edge> all;
bool mark[128];
void dfs(int u) {
  mark[u] = true;
  for (int i = 0; i <= 6; i++) {
    if (mark[i] == false && mat[u][i] > 0) dfs(i);
  }
}
int main() {
  cin >> n;
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    mat[a][b]++;
    mat[b][a]++;
    all.push_back(edge(a, b, i + 1, false));
    deg[a]++;
    deg[b]++;
  }
  int fard = 0;
  vector<int> v;
  for (int i = 0; i <= 6; i++)
    if (deg[i] & 1) {
      fard++;
      v.push_back(i);
    }
  int comp = 0;
  for (int i = 0; i <= 6; i++) {
    if (mark[i] == false && deg[i] > 0) {
      dfs(i);
      comp++;
    }
  }
  if (fard != 0 && fard != 2 || comp > 1) {
    cout << "No solution" << endl;
    return 0;
  }
  if (fard == 0) {
    int now = all[0].x;
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        if (all[j].x == now) {
          swap(all[i], all[j]);
          now = all[i].y;
          break;
        } else if (all[j].y == now) {
          swap(all[i], all[j]);
          all[i].rev = true;
          now = all[i].x;
          break;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      cout << all[i].id << " " << (all[i].rev == true ? '-' : '+') << endl;
    }
    return 0;
  }
  if (fard == 2) {
    int one = v[0];
    int two = v[1];
    for (int i = 0; i < n; i++) {
      if (all[i].x == two) {
        swap(all[n - 1], all[i]);
        swap(all[n - 1].x, all[n - 1].y);
        all[n - 1].rev = true;
        break;
      } else if (all[i].y == two) {
        swap(all[n - 1], all[i]);
        break;
      }
    }
    int bad = all[n - 1].x;
    bool mehdi = false;
    for (int i = 0; i < n - 1; i++) {
      if (all[i].x == one && all[i].y != bad) {
        swap(all[0], all[i]);
        mehdi = true;
        break;
      } else if (all[i].y == one && all[i].x != bad) {
        swap(all[0], all[i]);
        mehdi = true;
        swap(all[0].x, all[0].y);
        all[0].rev = true;
        break;
      }
    }
    if (mehdi == false) {
      for (int i = 0; i < n - 1; i++) {
        if (all[i].x == one) {
          swap(all[0], all[i]);
          mehdi = true;
          break;
        } else if (all[i].y == one) {
          swap(all[0], all[i]);
          mehdi = true;
          swap(all[0].x, all[0].y);
          all[0].rev = true;
          break;
        }
      }
    }
    int now = all[0].y;
    for (int i = 1; i < n - 1; i++) {
      bool found = false;
      for (int j = i; j < n - 1; j++) {
        if (all[j].x == now && all[j].y != bad) {
          swap(all[i], all[j]);
          now = all[i].y;
          found = true;
          break;
        } else if (all[j].y == now && all[j].x != bad) {
          swap(all[i], all[j]);
          now = all[i].x;
          all[i].rev = true;
          found = true;
          break;
        }
      }
      if (found == true) continue;
      for (int j = i; j < n - 1; j++) {
        if (all[j].x == now) {
          swap(all[i], all[j]);
          now = all[i].y;
          break;
        } else if (all[j].y == now) {
          swap(all[i], all[j]);
          now = all[i].x;
          all[i].rev = true;
          break;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      cout << all[i].id << " " << (all[i].rev == true ? '-' : '+') << endl;
    }
    return 0;
  }
  return 0;
}