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 JAVA):

Solution:
import com.sun.jmx.remote.internal.ArrayQueue;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Author   : Dylan
 * Date     : 2013-07-30
 * Time     : 10:04
 * Project  : Dominoes
 */
public class Main {
    static ArrayList<Bingo>[] p2d;
    static Domino[] dominoes;
    static boolean[] visited;
    static int[][] edges;
    static ArrayQueue<Integer> que;
    static int n;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        dominoes = new Domino[n + 1];
        edges = new int[7][7];
        p2d = new ArrayList[7];
        for(int i = 0; i < 7; i++) {
            p2d[i] = new ArrayList<Bingo>(n);
        }
        for(int i = 0; i < n; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            dominoes[i] = new Domino(x, y);
            p2d[x].add(new Bingo(i, false));
            p2d[y].add(new Bingo(i, true));
            edges[x][y]++;
            edges[y][x]++;
        }
        int cnt = 0, start = dominoes[0].right;
        for(int i = 0; i < 7; i++) {
            if(p2d[i].size() % 2 == 1) {
                start = i;
                cnt++;
            }
        }
        que = new ArrayQueue<Integer>(n + 1);
        if(!(cnt % 2 == 0 && cnt != 4 && dfs(start, 0))) {
            System.out.println("No solution");
        } else {
            que.add(start);
            visited = new boolean[n + 1];
            for(int i = 0; i < que.size() - 1; i++) {
                int t1 = que.get(i);
                int t2 = que.get(i + 1);
                for(Bingo j : p2d[t1]) {
                    if(!visited[j.domino] && dominoes[j.domino].getSide(j.turned) == t2) {
                        if(j.turned)
                            System.out.println(j.domino + 1 + " -");
                        else
                            System.out.println(j.domino + 1 + " +");
                        visited[j.domino] = true;
                        break;
                    }
                }
            }
        }
    }

    static boolean dfs(int lastPoints, int d) {
        if(d == n) return true;
        for(int i = 0; i < 7; i++) {
            if(edges[lastPoints][i] > 0) {
                edges[lastPoints][i]--;
                edges[i][lastPoints]--;
                if(dfs(i, d + 1)) {
                    que.add(i);
                    return true;
                }
                edges[lastPoints][i]++;
                edges[i][lastPoints]++;
            }
        }
        return false;
    }
}

class Bingo {
    int domino;
    boolean turned;

    Bingo(int domino, boolean turned) {
        this.domino = domino;
        this.turned = turned;
    }
}

class Domino {
    int left;
    int right;

    Domino(int left, int right) {
        this.left = left;
        this.right = right;
    }

    int getSide(boolean turned) {
        return turned ? left : right;
    }
}