#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, i, j, cnt = 0;
  cin >> k;
  char mat[k][k];
  int arr[17];
  for (i = 0; i < 17; i++) {
    arr[i] = 0;
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      cin >> mat[i][j];
      if (mat[i][j] != '.') {
        arr[mat[i][j] - '0']++;
      }
    }
  }
  for (i = 0; i < 17; i++) {
    if (arr[i] > 2 * k) {
      cnt = 1;
      break;
    }
  }
  if (cnt == 1)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
