a,b=(int(x) for x in input().split())
c,d=(int(x) for x in input().split())
e,f=(int(z) for z in input().split())
g,h=(int(s) for s in input().split())

if a==1:
    x=6000*b
    print(x)
    if c==2:
        y=4000*d
        print(y)
        if e==3:
            z=3000*f
            print(z)
        if e==4:
            z=2000*f
            print(z)
        if g==4:
            s=2000*h
            print(s)
        if g==3:
            s=3000*h
            print(s)
        
    if c==3:
        y=3000*d
        print(y)
        if e==2:
            z=4000*f
            print(z)
        if e==4:
            z=2000*f
            print(z)
        if g==4:
            s=2000*h
            print(s)
        if g==2:
            s=4000*h
            print(s)
        
    if c==4:
        y=2000*d
        print(y)
        if e==3:
            z=3000*f
            print(z)
        if e==2:
            z=4000*f
            print(z)
        if g==2:
            s=4000*h
            print(s)
        if g==3:
            s=3000*h
            print(s)

elif a==2:
    x=4000*b
    print(x)
    if c==1:
        y=6000*d
        print(y)
        if e==3:
            z=3000*f
            print(z)
        if e==4:
            z=2000*f
            print(z)
        if g==4:
            s=2000*h
            print(s)
        if g==3:
            s=3000*h
            print(s)
        
    if c==3:
        y=3000*d
        print(y)
        if e==1:
            z=6000*f
            print(z)
        if e==4:
            z=2000*nf
            print(z)
        if g==4:
            s=2000*h
            print(s)
        if g==1:
            s=6000*h
            print(s)
        
    if c==4:
        y=2000*d
        print(y)
        if e==3:
            z=3000*f
            print(z)
        if e==1:
            z=6000*f
            print(z)
        if g==1:
            s=6000*h
            print(s)
        if g==3:
            s=3000*h
            print(s)
        
elif a==3:
    x=3000*b
    print(x)
    if c==2:
        y=4000*d
        print(y)
        if e==1:
            z=6000*f
            print(z)
        if e==4:
            z=2000*f
            print(z)
        if g==4:
            s=2000*h
            print(s)
        if g==1:
            s=6000*h
            print(s)
        
    if c==1:
        y=6000*d
        print(y)
        if e==2:
            z=4000*f
            print(z)
        if e==4:
            z=2000*f
            print(z)
        if g==4:
            s=2000*h
            print(s)
        if g==2:
            s=4000*h
            print(s)
        
    if c==4:
        y=2000*d
        print(y)
        if e==1:
            z=6000*f
            print(z)
        if e==2:
            z=4000*f
            print(z)
        if g==2:
            s=4000*h
            print(s)
        if g==1:
            s=6000*h
            print(s)
        
else:
    x=2000*b
    print(x)
    if c==2:
        y=4000*d
        print(y)
        if e==3:
            z=3000*f
            print(z)
        if e==1:
            z=5000*f
            print(z)
        if g==1:
            s=6000*h
            print(s)
        if g==3:
            s=3000*h
            print(s)
        
    if c==3:
        y=3000*d
        print(y)
        if e==2:
            z=4000*f
            print(z)
        if e==1:
            z=6000*f
            print(z)
        if g==1:
            s=6000*h
            print(s)
        if g==2:
            s=4000*h
            print(s)
        
    if c==1:
        y=6000*d
        print(y)
        if e==3:
            z=3000*f
            print(z)
        if e==2:
            z=4000*f
            print(z)
        if g==2:
            s=6000*h
            print(s)
        if g==3:
            s=3000*h
            print(s)


Measured memory_bytes: 5832