Title: Taro's Shopping

Mammy wants to give Taro his first shopping experience. Taro needs to choose two items from a shopping catalogue. He wants to buy two different items with the highest price sum, not exceeding the allowed amount. Your task is to help Taro select the two items and report the sum. The input consists of multiple datasets, each containing the number of items, the maximum payment allowed, and the prices of the items. The output should indicate the pair with the highest price sum not exceeding the allowed amount, or "NONE" if no pair meets the criteria.

# Buggy version:
#!/usr/bin/env python3

n_list = []
m_list = []
a_list = []

while True:
    n, m = list(map(int, input().split(' ')))

    if n == 0 and m == 0:
        break

    a = list(map(int, input().split(' ')))

    n_list.append(n)
    m_list.append(m)
    a_list.append(a)


for n, m, a in zip(n_list, m_list, a_list):
    m_sum = 0
    for i in range(0, n):
        for j in range(i + 1, n):
            tmp = a[i] + a[j]
            if m_sum < tmp and tmp <= m:
                m_sum = tmp

    if m_sum > 0:
        print(m_sum)
    else:
        print('None')



# Fixed version:
#!/usr/bin/env python3

n_list = []
m_list = []
a_list = []

while True:
    n, m = list(map(int, input().split(' ')))

    if n == 0 and m == 0:
        break

    a = list(map(int, input().split(' ')))

    n_list.append(n)
    m_list.append(m)
    a_list.append(a)


for n, m, a in zip(n_list, m_list, a_list):
    m_sum = 0
    for i in range(0, n):
        for j in range(i + 1, n):
            tmp = a[i] + a[j]
            if m_sum < tmp and tmp <= m:
                m_sum = tmp

    if m_sum > 0:
        print(m_sum)
    else:
        print('NONE')

# Buggy version:
maxes=[]
cnt=0
while True:
    s=input()
    d=s.split()
    n=int(d[0])
    m=int(d[1])
    if n==0 and m==0:
        break

    s=input()
    d=s.split()
    a=[]
    
    for i in range(n):
        if int(d[i]) in a:
            n-=1
        else:
            a.append(int(d[i]))

    p=[[0 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(i+1,n):
            p[i][j]=(a[i]+a[j])


    max=0
    for i in range(n):
        for j in range(i+1,n):
            if p[i][j]>m:
                continue
            if max<p[i][j]:
                max=p[i][j]
    if max==0:
        maxes.append(-1)
    else:
        maxes.append(max)
    cnt+=1

for i in range(cnt):
    if maxes[i]==-1:
        print("NONE")
    else:
        print(maxes[i])



# Fixed version:
maxes=[]
cnt=0
while True:
    s=input()
    d=s.split()
    n=int(d[0])
    m=int(d[1])
    if n==0 and m==0:
        break

    s=input()
    d=s.split()
    a=[]
    
    for i in range(n):
        a.append(int(d[i]))

    p=[[0 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(i+1,n):
            p[i][j]=(a[i]+a[j])


    max=0
    for i in range(n):
        for j in range(i+1,n):
            if p[i][j]>m:
                continue
            if max<p[i][j]:
                max=p[i][j]
    if max==0:
        maxes.append(-1)
    else:
        maxes.append(max)
    cnt+=1

for i in range(cnt):
    if maxes[i]==-1:
        print("NONE")
    else:
        print(maxes[i])

# Buggy version:
while 1:
    str=input().split()
    n=int(str[0])
    m=int(str[1])
    if n==0 and m==0: break
    str=input().split()
    a=[0]*n
    for i in range(n):
        a[i]=int(str[i])
    a.sort()
    a.reverse()
    print(a)
    flag=0
    max=0
    for i in range(n):
        if flag!=0: break
        for j in range(i+1,n):
            v=a[i]+a[j]
            if m>=v:
                if max<v: max=v
    if max==0: print("NONE")
    else: print(max)



# Fixed version:
while 1:
    str=input().split()
    n=int(str[0])
    m=int(str[1])
    if n==0 and m==0: break
    str=input().split()
    a=[0]*n
    for i in range(n):
        a[i]=int(str[i])
    a.sort()
    a.reverse()
    flag=0
    max=0
    for i in range(n):
        if flag!=0: break
        for j in range(i+1,n):
            v=a[i]+a[j]
            if m>=v:
                if max<v: max=v
    if max==0: print("NONE")
    else: print(max)

# Buggy version:
s=[]

cnt=0

while 1:
    max=0
    n,m =map(int,input().split())
    l=list(map(int,input().split()))
    if n==0 and m==0:
        break

    for i in range(len(l)):
        for j in range(len(l)):
            if max<l[i]+l[j] and i!=j and m>=l[i]+l[j]:
                max=l[i]+l[j]

    if max==0:
        s+=["NONE"]
    else:
        s+=[max]


for x in s:
    print(x)



# Fixed version:

s=[]

cnt=0

while 1:
    max=0
    n,m =map(int,input().split())
    if n==0 and m==0:
        break
    l=list(map(int,input().split()))


    for i in range(len(l)):
        for j in range(len(l)):
            if max<l[i]+l[j] and i!=j and m>=l[i]+l[j]:
                max=l[i]+l[j]

    if max==0:
        s+=["NONE"]
    else:
        s+=[max]


for x in s:
    print(x)

# Buggy version:
maxs=[]
while(True):
    max=-1
    
    b=list(map(int,input().split()))
    n=b[0]
    m=b[1]
    if(n == 0 and m == 0):
        break
    a=list(map(int,input().split()))
    for i in range(n):
        for j in range(i+1,n):
            sum=a[i]+a[j]
            if(sum>max and sum=<m):
                max=sum
    maxs.append(max)

for i in maxs:
    if i==-1:
        print("NONE")
    else:
        print(i)



# Fixed version:
maxs=[]
while(True):
    max=-1
    
    b=list(map(int,input().split()))
    n=b[0]
    m=b[1]
    if(n == 0 and m == 0):
        break
    a=list(map(int,input().split()))
    for i in range(n):
        for j in range(i+1,n):
            sum=a[i]+a[j]
            if(sum>max and sum<=m):
                max=sum
    maxs.append(max)

for i in maxs:
    if i==-1:
        print("NONE")
    else:
        print(i)

# Buggy version:
n=5
m=5
z=0
sum=0
A=[]

while n!=0:
    n,m=[int(i) for i in input().split()]
    if n==0 and m==0:
        break
    val=[int(i) for i in input().split()]
    ans1=[int(0) for i in range(n)]
    ans2=[int(0) for i in range(n)]
    mm=0
    for i in range(0,n-1):
        for j in range(i+1,n):
            if i==j:
                break
            ans1[i]=val[i]+val[j]
        if ans1[i]>mm and ans1[i]<m:
            mm=ans1[i]

    A.append(mm)
    z=z+1

for i in range(z):
    if A[i]==0:
        A[i]="NONE"
    print(A[i])


# Fixed version:
n=5
m=5
z=0
sum=0
A=[]

while n!=0:
    n,m=[int(i) for i in input().split()]
    if n==0 and m==0:
        break
    val=[int(i) for i in input().split()]
    ans1=0
    mm=0
    for i in range(0,n):
        for j in range(i+1,n):
            if i==j:
                break
            ans1=val[i]+val[j]
            if ans1>mm and ans1<=m:
                mm=ans1
        ans1=0
    A.append(mm)
    z=z+1

for i in range(z):
    if A[i]==0:
        A[i]="NONE"
    print(A[i])

# Buggy version:
import sys
while(True):
    items=[]
    max=0
    n, m = map(int, input().split())
    if (n == 0 & m == 0):exit()
    items = list(map(int, input().split()))
    for i in range(n):
        for j in range(n):
            sum = items[i] + items[j]
            if (i != j and sum < m and sum > max):
                max = sum
    if (max == 0):
        print("NONE")
    else:
        print(max)



# Fixed version:
import sys
while(True):
    items=[]
    max=0
    n, m = map(int, input().split())
    if (n == 0 & m == 0):exit()
    items = list(map(int, input().split()))
    for i in range(n):
        for j in range(n):
            sum = items[i] + items[j]
            if (i != j and sum <= m and sum > max):
                max = sum
    if (max == 0):
        print("NONE")
    else:
        print(max)

# Buggy version:
while(True):
    max=0
    b=list(map(int,input().split()))
    n=b[0]
    m=b[1]
    if(n == 0 and m == 0):
        break
    a=list(map(int,input().split()))
    for i in range(n):
        for j in range(i+1,n):
            sum=a[i]+a[j]
            if(sum>max and sum<m):
                max=sum
    if m==0:
        print("NONE")
    else:
        print(max)





# Fixed version:
while True:
    n,m = map(int,input().split())
    if n == 0 and m == 0:
        break
    a = list(map(int,input().split()))
    
    b = 0
    for i in range(n):
        for j in range(i+1,n):
            if m < a[i] + a[j]:
                continue
            b = max(b,a[i] + a[j])
    if b == 0:
        print("NONE")
    else:
        print(b)

# Buggy version:
while 1:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    A=sorted(map(int, input().split()))
    def f():
        j = n-1
        yield 0
        for i in range(n):
            while j >= 0 and m < A[i]+A[j]:
                j -= 1
            if j >= 0:
                yield A[i] + A[j]
    print(max(f()) or"NONE")

# Fixed version:
while 1:
    n,m=map(int,input().split())
    if n==m==0:
        break
    A=sorted(map(int,input().split()))
    def f():
        j=n-1
        yield 0
        for i in range(n):
            while j >=0 and m<A[i]+A[j]:
                j-=1
            if j <=i:
                break
            if j >=0:
                yield A[i]+A[j]
    print(max(f())or"NONE")