import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
  
    public static void main(String[] args) {
        List<Rectangle> rectangles = new ArrayList<>();
        rectangles.add(new Rectangle(3, 4));
        rectangles.add(new Rectangle(5, 6));
        rectangles.add(new Rectangle(2, 2));
        rectangles.add(new Rectangle(8, 1));
        rectangles.add(new Rectangle(4, 4));

        System.out.println("Before sorting:");
        for (Rectangle r : rectangles) {
            System.out.println(r);
        }

        Collections.sort(rectangles);

        System.out.println("\nAfter sorting:");
        for (Rectangle r : rectangles) {
            System.out.println(r);
        }
    }
}