#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 7;
int pow(int a, int p) {
  int t = 1;
  for (int i = 0; i < p; i++) t *= a;
  return t;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> arr(m);
  for (int i = 0; i < m; i++) {
    cin >> arr[i].first >> arr[i].second;
    arr[i].first--;
  }
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    bool ok = true;
    string s = to_string(i);
    for (const auto &j : arr) {
      if (s[j.first] != j.second + '0') {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << s;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
