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

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

/* 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
	{
		BigInteger start = new BigInteger("1");
		BigInteger limit = new BigInteger("50");
		BigInteger n1 = new BigInteger("3");
		BigInteger n2 = new BigInteger("7");

		for (BigInteger a = start, b = start; a.compareTo(limit) <= 0 && b.compareTo(limit) <= 0;) {	
			BigInteger copas3 = a.multiply(n1);
			BigInteger copas7 = b.multiply(n2);

			int comparacao = copas3.compareTo(copas7); 
			if (comparacao == 0) {
				System.out.println(copas3);
			}
			
			if (comparacao <= 0) {
				a = a.add(BigInteger.ONE);
			}
			else {
				b = b.add(BigInteger.ONE);
			}
		}
	}
}