#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  pair<int, int> p[5];
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < (int)(M); i++) {
    cin >> p[i].first >> p[i].second;
  }
  int ans = -1;
  for (int i = pow(10, N - 1); i < pow(10, N) - 1; ++i) {
    string s = to_string(i);
    int len = s.length();
    bool judge = true;
    for (int j = 0; j < (int)(M); j++) {
      if (len < p[j].first) continue;
      if (s[p[j].first - 1] != (p[j].second + '0')) {
        judge = false;
        break;
      }
    }
    if (judge) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
