private static void GenerateVariation(Frame[] result, int position)
        {
            if (position == result.Length)
            {
                string posibleResult = string.Join(" | ", result.Select(x=>x));

                allResults.Add(posibleResult);

                return;
            }

            for (int i = 0; i < frames.Count; i++)
            {
                if (!used[i])
                {
                    result[position] = frames[i][0];
                    used[i] = true;
                    GenerateVariation(result, position + 1);
                    used[i] = false;
                    result[position] = frames[i][1];
                    used[i] = true;
                    GenerateVariation(result, position + 1);
                    used[i] = false;
                }
            }
        }
        static void Main(string[] args)
        {
            int numberOfFrames = int.Parse(Console.ReadLine());

            Frame[] result = new Frame[numberOfFrames];

            for (int i = 0; i < numberOfFrames; i++)
            {
                string line = Console.ReadLine();
                string[] tokens = line.Split(' ');
                int x = int.Parse(tokens[0]);
                int y = int.Parse(tokens[1]);
                if (x == y)
                {
                    frames.Add(new[] { new Frame(x, y), new Frame(x, y) });
                }
                else
                {
                    frames.Add(new[] { new Frame(x, y), new Frame(y, x) });
                }
            }

            used = new bool[frames.Count];
            GenerateVariation(result, 0);

            Console.WriteLine(allResults.Count);
            foreach (var item in allResults)
            {
                Console.WriteLine(item);
            }
        }