Cucumber boy is fan of Kyubeat, a famous music game.

Kyubeat has 16 panels for playing arranged in 4 × 4 table. When a panel lights up, he has to press that panel.

Each panel has a timing to press (the preffered time when a player should press it), and Cucumber boy is able to press at most k panels in a time with his one hand. Cucumber boy is trying to press all panels in perfect timing, that is he wants to press each panel exactly in its preffered time. If he cannot press the panels with his two hands in perfect timing, his challenge to press all the panels in perfect timing will fail.

You are given one scene of Kyubeat's panel from the music Cucumber boy is trying. Tell him is he able to press all the panels in perfect timing.


-----Input-----

The first line contains a single integer k (1 ≤ k ≤ 5) — the number of panels Cucumber boy can press with his one hand.

Next 4 lines contain 4 characters each (digits from 1 to 9, or period) — table of panels. If a digit i was written on the panel, it means the boy has to press that panel in time i. If period was written on the panel, he doesn't have to press that panel.


-----Output-----

Output "YES" (without quotes), if he is able to press all the panels in perfect timing. If not, output "NO" (without quotes).


-----Examples-----
Input
1
.135
1247
3468
5789

Output
YES

Input
5
..1.
1111
..1.
..1.

Output
YES

Input
1
....
12.1
.2..
.2..

Output
NO



-----Note-----

In the third sample boy cannot press all panels in perfect timing. He can press all the panels in timing in time 1, but he cannot press the panels in time 2 in timing with his two hands.

Difficulty: interview

Starter code:

Solutions:
k=int(input())

L={}
s=".123456789"
for item in s:
    L[item]=0
for i in range(4):
    s=input()
    for item in s:
        L[item]+=1

s="123456789"
done=True
for item in s:
    if(L[item]>2*k):
        print("NO")
        done=False
        break
if(done):
    print("YES")


k = int(input())
a = [list(input()) for i in range(4)]
x = [0 for i in range(10)]
for i in range(4):
	for j in range(4):
		if a[i][j] == '.': continue
		n = int(a[i][j])
		x[n]+=1
ok = True
for i in range(10):
	if x[i] > 2*k:
		ok = False
if (ok):
	print("YES")
else:
	print("NO")


k = int(input())
a = [0] * 10
for i in range(4):
    s = input()
    for j in range(4):
        if s[j] != '.':
            a[int(s[j])]+=1
ans = 'YES'
for i in range(10):
    if 2 * k < a[i]:
        ans = 'NO'
print(ans)

k = int(input())
A = [input().strip() for i in range(4)]
cnt = [0 for i in range(10)]
flag = False
for y in range(4):
    if flag:
        break
    for x in range(4):
        c = A[y][x]
        if c == '.':
            continue
        cnt[int(c)] += 1
        if cnt[int(c)] > 2 * k:
            print("NO")
            flag = True
            break

if not(flag):
    print("YES")


k = int(input())
panel1 = input()
panel2 = input()
panel3 = input()
panel4 = input()
can = True

for i in range(1,10):
    counter = panel1.count(str(i)) + panel2.count(str(i)) + panel3.count(str(i)) + panel4.count(str(i))
    if counter > k*2 :
        can = False
        break
if can :
    print("YES")
else:
    print("NO")


k=int(input())
z=[]
x1=input()
for i in range (0,len(x1)):
    if (x1[i] != '.'):
        z.append(int(x1[i]))
    else:
        continue

x2=input()
for l in range (0,len(x2)):
    if (x2[l] != '.'):
        z.append(int(x2[l]))
    else:
        continue


x3=input()
for y in range (0,len(x3)):
    if (x3[y] != '.'):
        z.append(int(x3[y]))
    else:
        continue

x4=input()
for s in range (0,len(x4)):
    if (x4[s] != '.'):
        z.append(int(x4[s]))
    else:
        continue


key=len(set(z))

copy=list(set(z))
count=0
for j in range (0,len(copy)):
    if (z.count(copy[j])<= 2*k):
        count+=1
    else:
        count=count


if (count==key):
    print ("YES")
else:
    print ("NO")
    


k = int(input())

panels = {'1':0, '2':0, '3':0, '4':0, '5':0, '6':0, '7':0, '8':0, '9':0}
flag = True

for i in range(4):
    line = input()
    for ch in line:
        if ch == '.' :
            continue
        panels[ch] += 1

v = list(panels.values())

for i in v:
    if i > 2 * k:
        flag = False #print('NO')

#print(panels)
if flag :
    print('YES')
else:
    print('NO')


k=int(input())
c=[0]*9
for i in range(4):
    a=input().strip()
    for i in a:
        if i!='.':
            c[int(i)-1]+=1
if max(c)<=2*k:
    print('YES')
else:
    print('NO')

3

def readln(): return tuple(map(int, input().split()))

k, = readln()
cnt = {}
for c in list(''.join([input() for _ in range(4)])):
    if c != '.':
        cnt[c] = cnt.get(c, 0) + 1
print('YES' if len([1 for v in list(cnt.values()) if v <= 2 * k]) == len(cnt) else 'NO')


k = int(input())

t = ["" for i in range(4)]
for i in range(4):
	t[i] = input()

cnt = [0 for i in range(10)]

for i in range(4):
	for j in range(4):
		if t[i][j] != '.':
			cnt[int(t[i][j])] += 1

if max(cnt) <= k * 2:
	print("YES")
else:
	print("NO")


k = int(input())
p = {i: 0 for i in '123456789.'}
for i in range(4):
    for j in input(): p[j] += 1
p['.'] = 0
print('YNEOS'[max(p.values()) > 2 * k :: 2])

k = int(input())
count = {i:0 for i in "123456789."}

for i in range(4):
    for string in input():
        count[string] += 1;

count["."] = 0

if max(count.values()) > 2*k:
    print("NO")
else:
    print("YES")


k=int(input())
g=''
for i in range(4):
    g = g+input()
#print(g)
valid=True
for i in range(1,10):
    if g.count(str(i))>2*k:
        valid=False
        break
if valid:
    print('YES')
else:
    print('NO')


k=int(input())*2
s=''.join(input() for _ in range(4))
if max(s.count(c) for c in '0123456789')>k:
    print ('NO')
else:
    print('YES')

__author__ = 'asmn'

k=int(input())
cnt=dict((i,0) for i in range(1,10))
for i in range(4):
    for j in input():
        if ord('1')<=ord(j)<=ord('9'):
            cnt[ord(j)-ord('0')]+=1
print('YES' if len(list([x for x in list(cnt.items()) if x[1]>2*k]))==0 else 'NO')


a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
k = int(input())
for i in range(0, 4):
    b = input()
    for j in range(0, 4):
        if b[j] != '.':
            a[int(b[j])] += 1
for i in range(0, 10):
    if a[i] > k * 2:
        print ("NO")
        return
print("YES")


k = int(input())
s = ''
n = list()
for i in range(4):
    a = input()
    s = s + a
for i in range(1,10):
    n.append(s.count(str(i)))
if max(n)> 2*k:
    print ('NO')
else:
    print ('YES')


def collecting(k):
	n = [k*2]*9
	for t in range(4):
		for c in input():
			if c != '.':
				i = int(c)-1
				n[i] -= 1
				if n[i] < 0:
					print('NO')
					return
	print('YES')
	return

def main():
	k = int(input())
	collecting(k)

def __starting_point():
	main()
__starting_point()

k = 2*int(input())
l1 = input()
l2 = input()
l3 = input()
l4 = input()
times = [0,0,0,0,0,0,0,0,0]
for cont in range(0,4):
    for tmp in range(1,10):
        if l1[cont] == str(tmp):
            times[tmp-1] += 1
        if l2[cont] == str(tmp):
            times[tmp-1] += 1
        if l3[cont] == str(tmp):
            times[tmp-1] += 1
        if l4[cont] == str(tmp):
            times[tmp-1] += 1

l = True
for tmp in times:
    if tmp > k:
        l = False

if l == True:
    print('YES')
else:
    print('NO')

a=int(input())
allp=""
for i in range(4):
    allp+=input()
okay="YES"
for i in range(9):
    if allp.count(str(i+1))>a*2:
        okay="NO"
        break
print(okay)

# -*- coding: utf-8 -*-

k = int(input())

counter = [0] * 10
s = ''.join([input().strip() for i in range(4)])

for c in s:
    if c == '.':
        continue
    counter[int(c)] += 1

m = max(counter)
print('NO' if m > 2*k else 'YES')

k = int(input())
s = ''.join(input().replace('.', '') for i in range(4))
print("NO" if len(s) > 0 and max(s.count(c) for c in set(s)) > 2 * k else "YES")

nums = [0 for i in range(10)]
k = int(input())

for i in range(4):
	s = input()
	for c in s:
		if c != '.':
			nums[int(c)] += 1

if all(nums[i] <= 2*k for i in range(10)):
	print('YES')
else:
	print('NO')


k = int(input())

l = [0] * 10

for i in range(4):
    for j in input():
        if (j != '.'):
            l[int(j)] += 1
for i in range(10):
    if l[i] > k*2:
        print("NO")
        return
print("YES")





"""k = []
for i in range(5):
    k.append([int(x) for x in (sys.stdin.readline()).split()])
    
vmax = 0 
tt = []
for i in range(5):
    for j in range(i, 5):
        if(i != j):
            k[i][j] = k[j][i] = k[i][j] + k[j][i]
                

for i in range(5):
    print(k[i])"""
  
  
import sys
import math
  
n = int(sys.stdin.readline())

k = [0] * 9

for i in range(4):
    tt = sys.stdin.readline()
    for j in range(4):
        if(tt[j] != '.'):
            ind = ord(tt[j]) - ord('0') - 1
            k[ind] += 1
            if(k[ind] > n * 2):
                print("NO")
                return
                
print("YES")