/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone {
	
	public static void main (String[] args) throws java.lang.Exception {
		final Collideable a = new Asteroid();
        final Collideable s = new Spaceship();
        a.collideWith(a);
        a.collideWith(s);
        s.collideWith(a);
        s.collideWith(s);
	}
}

interface Collideable {

    default void collideWith(Collideable other) {
        // Call collideWith on the other object.
        other.collideWith(this);
    }

    /* These methods would need different names in a language without method overloading. */
    void collideWith(Asteroid asteroid);
    void collideWith(Spaceship spaceship);
}

class Asteroid implements Collideable {

    public void collideWith(Asteroid asteroid) {
        System.out.println("AA");
    }

    public void collideWith(Spaceship spaceship) {
        System.out.println("AS");
    }
}

class Spaceship implements Collideable {

    public void collideWith(Asteroid asteroid) {
        System.out.println("SA");
    }

    public void collideWith(Spaceship spaceship) {
        System.out.println("SS");
    }
}
