Problem:


Bamboo Blossoms

  The bamboos live for decades, and at the end of their lives,
  they flower to make their seeds.  Dr. ACM, a biologist, was fascinated
  by the bamboos in blossom in his travel to Tsukuba.  He liked
  the flower so much that he was tempted to make a garden where
  the bamboos bloom annually.  Dr. ACM started research of
  improving breed of the bamboos, and finally, he established
  a method to develop bamboo breeds with controlled lifetimes.
  With this method, he can develop bamboo breeds that flower
  after arbitrarily specified years.

  Let us call bamboos that flower k years after sowing
  "k-year-bamboos."
  k years after being sowed, k-year-bamboos make
  their seeds and then die,
  hence their next generation flowers after another k years.
  In this way, if he sows seeds of k-year-bamboos, he can
  see bamboo blossoms every k years.  For example,
  assuming that he sows seeds of 15-year-bamboos,
  he can see bamboo blossoms every 15 years;
  15 years, 30 years, 45 years, and so on, after sowing.

  Dr. ACM asked you for designing his garden.  His garden is partitioned
  into blocks, in each of which only a single breed of bamboo can grow.
  Dr. ACM requested you to decide which breeds of bamboos
  should he sow in the blocks in order to see bamboo blossoms
  in at least one block for as many years as possible.

  You immediately suggested to sow seeds of one-year-bamboos in all blocks.
  Dr. ACM, however, said that it was difficult to develop a bamboo breed
  with short lifetime, and would like a plan using only those breeds with
  long lifetimes.  He also said that, although he could wait for some years
  until he would see the first bloom, he would like to see it in
  every following year.
  Then, you suggested a plan
  to sow seeds of 10-year-bamboos, for example, in different blocks each year,
  that is, to sow in a block this year and in another block next year, and so on,
  for 10 years.  Following this plan, he could see
  bamboo blossoms in one block every year except for the first 10 years.
  Dr. ACM objected again saying he had determined to sow in all
  blocks this year.

  After all, you made up your mind to make a sowing plan where the bamboos
  bloom in at least one block for as many consecutive years as possible
  after the first m years (including this year)
  under the following conditions:
  

    
the plan should use only those bamboo breeds whose
      lifetimes are m years or longer, and
    
Dr. ACM should sow the seeds in all the blocks only this year.
  

Input

  The input consists of at most 50 datasets, each in the following format.

    m n

  An integer m (2 ≤ m ≤ 100) represents the lifetime
  (in years)
  of the bamboos with the shortest lifetime that Dr. ACM can use for
  gardening.
  An integer n (1 ≤ n ≤ 500,000) represents the number of blocks.

The end of the input is indicated by a line containing two zeros.

Output

  No matter how good your plan is, a "dull-year" would
  eventually come, in which the bamboos do not flower in any block.
  For each dataset, output in a line an integer meaning how many
  years from now the first dull-year comes after the first m years.

  Note that the input of m = 2 and n = 500,000
  (the last dataset of the Sample Input) gives the largest answer.

Sample Input

3 1
3 4
10 20
100 50
2 500000
0 0

Output for the Sample Input

4
11
47
150
7368791



Sample input:
3 1
3 4
10 20
100 50
2 500000
0 0


Sample output:
4
11
47
150
7368791

Submission status: Runtime Error

Solution code:
while True:
    m, n = map(int,input().split())
    if m == 0 and n == 0:
        break
    sea = []
    pri = []
    for i in range(0, 7368792):
        sea.append(True)
        #print(sea)
    """くそ長すぎて笑える
    for i in range(0, 7368792-m):
        pri.append(sea[i])
        print(sea[i], i,"in")
    for i in range(0, 7368792-m):
        pri.append(sea[0])
        for j in range(0, len(sea)):
            if sea[j]%pri[i] == 0:
                #print(pri[i], "m")
                #print(sea[j], "del")
                sea.remove(sea[j])
                #break
        if len(pri) > n:
            print(pri[-1])
            break
    """
    #nが500000になると死ぬ
    for i in range(0, m):
        sea[i] = False
    for i in range(m, len(sea)):
        if sea[i] == True:
            pri.append(i)
            if len(pri) > n:
                print(pri[-1])
                break
            for j in range(i, len(sea), i):
                sea[j] = False
"""removeするとindexずれるわ
while True:#ver_Sieve_of_Eratosthenes
    m, n = map(int,input().split())
    if m == 0 and n == 0:
        break
    pri = list()
    sea = list()
    for i in range(2, 7368792):
        sea.append(i)
    for i in range(m, 7368792):
        pri.append(sea[i-2])
        print(pri)
        for j in range(0,len(sea)):
            if sea[j]%i == 0:
                sea.remove(sea[j])
                break
        if len(pri) > n:
            print(pri)
            print(pri[-1])
            break
"""

Submission status: Runtime Error

Solution code:
while True:
    m, n = map(int,input().split())
    if m == 0 and n == 0:
        break
    sea = []
    pri = []
    for i in range(0, 7368792):
        sea.append(True)
        #print(sea)
    for i in range(0, m):
        sea[i] = False
    for i in range(m, len(sea)):
        if sea[i] == True:
            pri.append(i)
            if len(pri) > n:
                print(pri[-1])
                break
            for j in range(i, len(sea), i):
                sea[j] = False

Submission status: Runtime Error

Solution code:
while True:
    m, n = map(int,input().split())
    if m == 0 and n == 0:
        break
    sea = []
    #pri = []
    co = 0
    for i in range(0, 7368792):
        sea.append(True)
    for i in range(0, m):
        sea[i] = False
    for i in range(m, len(sea)):
        if sea[i] == True:
            co = co + 1
            #pri.append(i)
            if co > n:
                print(sea.index(True))
                break
            for j in range(i, len(sea), i):
                sea[j] = False

Submission status: Runtime Error

Solution code:
while True:
    m, n = map(int,input().split())
    if m == 0 and n == 0:
        break
    sea = []
    #pri = []
    co = 0
    for i in range(m, 7368792):
        sea.append(True)
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            #pri.append(i)
            if co > n:
                print(sea.index(True)+m)
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False

Submission status: Runtime Error

Solution code:
while True:
    m, n = map(int,input().split())
    if m == 0 and n == 0:
        break
    sea = []
    #pri = []
    co = 0
    sea = [True]*(7368792-m)
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            #pri.append(i)
            if co > n:
                print(sea.index(True)+m)
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False

Submission status: Runtime Error

Solution code:
while True:
    m, n = map(int,input().split())
    if m == 0 and n == 0:
        break
    sea = [True]*(7368792-m)
    co = 0
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            if co > n:
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False
    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
a = 0
while True:
    m, n = map(int,input().split())
    if m == 0 and n == 0 and a == 0:
        a = a+1
        continue
    elif m == 0 and n == 0 and a == 1:
        break
    sea = [True]*(7368792-m)
    co = 0
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            if co > n:
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False
    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
while True:
    m, n = map(int,input().split())
    if m == 0:
        break
    sea = [True]*(7368792-m)
    co = 0
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            if co > n:
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False
    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
while True:
    m, n = map(int,input().split())
    if m == 0:
        break
    sea = [True]*(7500111-m)
    co = 0
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            if co > n:
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False
    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
while True:

    m, n = map(int,input().split())

    if m == 0 and n == 0:

        break

    sea = [True]*(7368792-m)

    co = 0

    for i in range(0, len(sea)):

        if sea[i] == True:

            co = co + 1

            if co > n:

                break

            for j in range(i, len(sea), i+m):

                sea[j] = False

    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
while True:

    m, n = map(int,input().split())

    if m == 0 and n == 0:

        break

    sea = 8000000 #[True]*(7368792-m)

    co = 0

    for i in range(0, len(sea)):

        if sea[i] == True:

            co = co + 1

            if co > n:

                break

            for j in range(i, len(sea), i+m):

                sea[j] = False

    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
while True:

    m, n = map(int,input().split())

    if m == 0 and n == 0:

        break

    sea = [True]*8000000 #[True]*(7368792-m)

    co = 0

    for i in range(0, len(sea)):

        if sea[i] == True:

            co = co + 1

            if co > n:

                break

            for j in range(i, len(sea), i+m):

                sea[j] = False

    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
while True:

    m, n = map(int,input().split())

    if m == 0 and n == 0:

        break

    sea = [True]*8000000

    co = 0

    for i in range(0, len(sea)):

        if sea[i] == True:

            co = co + 1

            if co > n:

                break

            for j in range(i, len(sea), i+m):

                sea[j] = False

    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
while True:
    m, n = list(map(int,input().split()))
    if m == 0 and n == 0:
        break
    sea = [True]*(7368792-m)
    co = 0
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            if co > n:
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False
    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
while True:
    m, n = map(int,input().split())
    if m == 0 and n == 0:
        break
    sea = [True]*(7368792-m)
    co = 0
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            if co > n:
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False
    for i in range(0,len(sea)):
        if sea[i] == True:
            co = i+m
            break
    #print(sea.index(True)+m)
    print(co)

Submission status: Runtime Error

Solution code:
while True:
    m, n = [int(i) for i in input().split()]
    if m == 0 and n == 0:
        break
    sea = [True]*(7368792-m)
    co = 0
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            if co > n:
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False
    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
while True:
    m, n = [int(i) for i in input().split()]
    if m == 0 and n == 0:
        break
    sea = [True for i in range(0,7368792-m)]#[True]*(7368792-m)
    co = 0
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            if co > n:
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False
    print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
while True:
    m, n = [int(i) for i in input().split()]
    if m == 0 and n == 0:
        break
    sea = [True for i in range(0,7368792-m)]#[True]*(7368792-m)
    co = 0
    for i in range(0, len(sea)):
        if sea[i] == True:
            co = co + 1
            if co > n:
                break
            for j in range(i, len(sea), i+m):
                sea[j] = False
    for i in range(0,len(sea)):
        if sea[i]:
            print(i+m)
            break
    #print(sea.index(True)+m)

Submission status: Runtime Error

Solution code:
def inpl(): return list(map(int, input().split()))
M, N = inpl()
lim = 7368791 + 1

while N:
    years = [False]*(lim)
    for i in range(M, lim):
        if years[i] == False:
            if N == 0:
                print(i)
                break
            for j in range(i, lim, i):
                years[j] = True
            N -= 1
    M, N = inpl()