import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
public class Ans {
public static void main(String[] args) {
C c = new C(3);
System.out.println(c);
}
}
interface Generator<T> {
T next();
}
class Generators {
static <T> Collection<T> fill(Collection<T> coll,Generator<T> gen,int num) {
for (int i = 0;i<num;++i) coll.add(gen.next());
return coll;
}
}
class A {
A() {a = count++; }
@Override
public String toString() {
return "A{" +
"a=" + a +
'}';
}
int a;
static int count = 0;
static Generator<A> generator = new Generator<A>() {
@Override
public A next() {
return new A();
}
};
}
class B extends ArrayList<A> {
B(int n) {
Generators.fill(this,A.generator,n);
}
}
class C extends ArrayList<B> {
C(int n) {
for (int i = 0;i<n;++i) this.add(new B(3));
}
}