public static void main(String[] a) throws IOException {
		Scanner s = new Scanner(new File(a[0]));
		while (s.hasNext()) {
			String l = s.nextLine();
			String[] x = l.split("\\ ");
			int[] y = new int[x.length];
			
			for (int i = 0; i < x.length; i++) {
				y[i] = Integer.parseInt(x[i]);
			}
			
			boolean f = false;
			int[] y1, y2;
			for (int i = 1; i < y.length/2; i++) {// length of substring
				if (f) {
					break;
				}
				for (int j = 0; j < y.length - i; j++) {// starting
					y1 = Arrays.copyOfRange(y, j, i+j);
					y2 = Arrays.copyOfRange(y, j+i, y.length);
					if (c(y2, d(y1))) {
						y = y1;
						f = true;
						break;
					}
				}
			}
			
			StringBuffer u = new StringBuffer();
			for (int i = 0; i < y.length; i++) {
				u.append(y[i]);
				if (i < y.length - 1) {
					u.append(' ');
				}
			}
			System.out.println(u.toString());
		}
	}