import java.lang.Boolean;
import java.lang.Object;

sealed interface List<T> permits Cons, Empty {}

public record Cons<T>(T a, List<T> l) implements List<T> {}
public record Empty<T>() implements List<T> {}

public class PatternMatchingListAppend {

    public append(Cons(a, b), list2) {
        return new Cons<>(a, append(b, list2));
    }

    public append(Empty(), list2) {
        return list2;
    }

    /*public append(a, list2) {
        switch(a) {
            case Cons(x, y) -> ...
            case Empty() ->
        }
    }*/

}