public void Run() { var strings = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var amountOfRemoves = int.Parse(Console.ReadLine()); var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); foreach (var stringItem in strings) { try { this.Dictionary["addCollection"].Add(addCollection.Add(stringItem)); this.Dictionary["addRemoveCollection"].Add(addRemoveCollection.AddAtBeginning(stringItem)); this.Dictionary["myList"].Add(myList.AddAtBeginning(stringItem)); } catch (Exception e) { } } for (int i = 0; i < amountOfRemoves; i++) { this.AddRemoveList.Add(addRemoveCollection.RemoveLastItem()); this.MyList.Add(myList.RemoveFirstElement()); } }