#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k;
  cin >> n;
  char arr[4][4];
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      cin >> arr[i][j];
    }
  }
  int t[9] = {'1', '2', '3', '4', '5', '6', '7', '8', '9'};
  int total[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  int count;
  for (k = 0; k < 9; k++) {
    count = 0;
    for (i = 0; i < 4; i++) {
      for (j = 0; j < 4; j++) {
        if (arr[i][j] == t[k]) count++;
      }
    }
    total[k] = count;
  }
  int flag = 0;
  for (i = 0; i < 9; i++) {
    if (total[i] > 2 * n) {
      flag = 1;
    }
  }
  if (flag == 0) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
