#include <bits/stdc++.h>
using namespace std;
int powInt(int a, int b) {
  int ans = 1;
  for (int i = 0; i < b; ++i) {
    ans *= a;
  }
  return ans;
}
int main() {
  int n, m;
  cin >> n >> m;
  int ans = powInt(10, n - 1);
  vector<pair<int, char>> constraint(m);
  for (int i = 0; i < m; ++i) {
    cin >> constraint[i].first >> constraint[i].second;
    if (constraint[i].first == 1 && constraint[i].second == '0') {
      cout << -1 << endl;
      return 0;
    }
  }
  bool flag;
  for (int j = ans; j < powInt(10, n); ++j) {
    string s = to_string(j);
    flag = true;
    for (pair<int, char> k : constraint) {
      if (s[k.first - 1] != k.second) {
        flag = false;
        break;
      }
    }
    if (flag) {
      cout << j << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
