Implement a method that adds an element to the beginning of a linked list and another at the end.