Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all *n* dragons that live on this level. Kirito and the dragons have strength, which is represented by an integer. In the duel between two opponents the duel's outcome is determined by their strength. Initially, Kirito's strength equals *s*.

If Kirito starts duelling with the *i*-th (1 ≤ *i* ≤ *n*) dragon and Kirito's strength is not greater than the dragon's strength *x*<sub class="lower-index">*i*</sub>, then Kirito loses the duel and dies. But if Kirito's strength is greater than the dragon's strength, then he defeats the dragon and gets a bonus strength increase by *y*<sub class="lower-index">*i*</sub>.

Kirito can fight the dragons in any order. Determine whether he can move on to the next level of the game, that is, defeat all dragons without a single loss.
The first line contains two space-separated integers *s* and *n* (1 ≤ *s* ≤ 10<sup class="upper-index">4</sup>, 1 ≤ *n* ≤ 10<sup class="upper-index">3</sup>). Then *n* lines follow: the *i*-th line contains space-separated integers *x*<sub class="lower-index">*i*</sub> and *y*<sub class="lower-index">*i*</sub> (1 ≤ *x*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">4</sup>, 0 ≤ *y*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">4</sup>) — the *i*-th dragon's strength and the bonus for defeating it.
strength,dragon_num=[int(x) for x in input().split()]
dragons_strength={}
dragons_bonus={}

i=0
for dragon_strength in input().split():
   i += 1
   dragons_strength[i] = int(dragon_strength)

j=0
for dragon_bonus in input().split():
    j += 1
    dragons_bonus[j] = int(dragon_bonus)

dragons_strength_modified={}
for k in sorted(dragons_strength.items(),key=lambda m:m[1]):
    dragons_strength_modified[k[0]] = k[1]

#这里有一个小分歧：一种是：按照已有字典顺序去排另外一个字典
#另外就是字典包字典
#此处用第一种方法先写：

#dragons_bonus_modified = {j:dragons_bonus[j] for j in dragons_strength_modified.keys()}
#这里和下面u=0都可以一步优化，因为最开始别人提供的就是这种方法，让我们直接优化到最后仍然是顺序1 2 3，但是已经经历了value的转换
dragons_bonus_modified = {j:dragons_bonus[j] for j in sorted(dragons_strength_modified.keys())}
dragons_strength_modified_modified={}
#dragons_bonus_modified_modified={}
l=0
for value in dragons_strength_modified.values():
    l += 1
    dragons_strength_modified_modified[l] = value

#u=0
#for value in dragons_bonus_modified.values():
#    u += 1
#    dragons_bonus_modified_modified[u] = value

for key in dragons_strength_modified_modified:
    if key < l:
        test_list=[]
        test_list.append(key)
        test=True
        o=1
        while test:
            if dragons_strength_modified_modified[key] == dragons_strength_modified_modified[key+o] :
                test_list.append(key+o)
                o += 1
                if key+o > l:
                    test=False
            else:
                test=False
        key_test=test_list[0]
        for value_specific in sorted([dragons_bonus_modified[key_specific] for key_specific in test_list]):
            dragons_bonus_modified[key_test] = value_specific
            if key_test != test_list[-1]:
                key_test += 1

p=1
dul=True
while dul:
    if p > l:
        dul = False
        print("YES")
    elif strength > dragons_strength_modified_modified[p]:
        strength += dragons_bonus_modified[p]
        p += 1
    else:
        dul = False
        print("NO")