#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
bool isLowerCase(char c) { return (c >= 'a' && c <= 'z'); }
const string btos(bool ans) { return (ans ? "Yes" : "No"); }
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  vector<pair<int, char>> cond(m);
  int cnt = pow(10, n);
  for (int i = 0; i < (int)(m); i++) {
    int si;
    cin >> si;
    char ci;
    cin >> ci;
    cond[i] = pair<int, char>(si - 1, ci);
  }
  for (int i = 0; i < (int)(cnt); i++) {
    string s = to_string(i);
    bool match = true;
    if (s.size() != n) {
      match = false;
      continue;
    }
    for (int j = 0; j < (int)(m); j++) {
      if (s[cond[j].first] != cond[j].second) {
        match = false;
        break;
      }
    }
    if (match) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
