#include <bits/stdc++.h>
const double PI = 3.14159265358979323846;
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<pair<int, char>> v(m);
  for (int i = 0; i < (m); i++) {
    int s;
    char c;
    cin >> s >> c;
    v[i] = make_pair(s, c);
  }
  int ans = -1;
  for (int i = pow(10, n - 1); i < pow(10, n); ++i) {
    string num = to_string(i);
    bool can = true;
    for (auto itr = v.begin(); itr != v.end(); ++itr) {
      if (num[itr->first - 1] != itr->second) {
        can = false;
        break;
      }
    }
    if (can) {
      ans = i;
      break;
    }
  }
  cout << (ans) << "\n";
}
