/* 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 Runner {
	public static void main (String[] args) throws java.lang.Exception {
		for (int i = 0; i < 50; i++) {
			new Example();
		}
		for (Example e : Example.examples) {
			System.out.println("Ad ID: " + e.ID);
		}
	}
}

class Example {
	
	public final int ID;
	
	public static ArrayList<Example> examples = new ArrayList<Example>();
	
	public Example() {
		this(newRandomID());
	}
	
	public Example(int ID) {
		this.ID = ID;
		examples.add(this);
	}
	
	public static int newRandomID() {
		Random rnd = new Random();
		int randomID = rnd.nextInt(999999);
		while (idExists(randomID)) {
			randomID = rnd.nextInt(999999);
		}
		return randomID;
	}
	
	public static boolean idExists(int ID) {
		for (Example e : examples) {
			if (e.ID == ID) {
				return true;
			}
		}
		return false;
	}
	
}