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 javax.crypto.Cipher;
import java.io.*;
import java.util.*;

public class Solution {
    static Graph readData() {
        Scanner in = new Scanner(System.in);
        int m = in.nextInt();
        Graph graph = new Graph(m);
        for (int i = 0; i < m; i++) {
            int v = in.nextInt();
            int w = in.nextInt();
            graph.addEdge(v, w, i + 1);
        }
        return graph;
    }

    static class Graph {
        boolean bad = false;
        boolean[] used;
        int[] deg;
        int n;
        int m;
        int[][] g;
        LinkedList<Integer>[][] edges;
        List<Integer> eulerPath;

        public Graph(int m) {
            this.n = 7;
            this.m = m;
            deg = new int[n];
            edges = new LinkedList[n][n];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    edges[i][j] = new LinkedList<>();
            eulerPath = new ArrayList<>();
        }

        void addEdge(int v, int w, int c) {
            deg[v]++;
            deg[w]++;
            edges[v][w].add(c);
        }

        boolean dfs(int u, int v) {
            if (u == v)
                return true;
            used[u] = true;
            for (int i = 0; i < n; i++)
                if (!used[i])
                    if (edges[u][i].size() > 0 || edges[i][u].size() > 0)
                        if (dfs(i, v))
                            return true;
            return false;
        }

        boolean isConnectedGraph() {
            used = new boolean[n];
            for (int i = 0; i < n; i++) {
                if (deg[i] > 0) {
                    dfs(i, -1);
                    break;
                }
            }
            for (int i = 0; i < n; i++) {
                if (deg[i] > 0 && !used[i])
                    return false;
            }
            return true;
        }

        void findEulerPath() {
            List<Integer> odd = new ArrayList<>();
            for (int i = 0; i < n; i++)
                if (deg[i] % 2 != 0)
                    odd.add(i);
            if (odd.size() > 2 || !isConnectedGraph())
                bad = true;
            int start = -1;
            if (!odd.isEmpty())
                start = odd.get(0);
            if (start == -1)
                for (int i = 0; i < n; i++)
                    if (deg[i] > 0)
                        start = i;
            printEulerPath(start);
        }

        void printEulerPath(int u) {
            PrintWriter out = new PrintWriter(System.out, true);
            StringBuilder res = new StringBuilder();
            if (bad) {
                res.append("No solution");
            } else {
                for (int i = 0; i < m; i++) {
                    int selIdx = -1;
                    boolean reversed = false;
                    for (int j = 0; j < n; j++) {
                        if (edges[u][j].size() > 0 ||
                                edges[j][u].size() > 0) {
                            int idx;
                            boolean rev;
                            if (edges[u][j].size() > 0) {
                                idx = edges[u][j].pollLast();
                                rev = true;
                            } else {
                                idx = edges[j][u].pollLast();
                                rev = false;
                            }
                            deg[u]--;
                            deg[j]--;

                            used = new boolean[n];
                            if (deg[u] == 0 || dfs(u, j)) {
                                selIdx = idx;
                                reversed = rev;
                                u = j;
                                break;
                            } else {
                                if (rev)
                                    edges[u][j].add(idx);
                                else
                                    edges[j][u].add(idx);
                                deg[u]++;
                                deg[j]++;
                            }
                        }
                    }
                    res.append(selIdx).append(' ').append(reversed ? '+' : '-').append('\n');
                }
            }
            out.print(res);
            out.close();
        }
    }

    public static void main(String[] args) {
        Graph graph = readData();
        graph.findEulerPath();
    }
}