#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  vector<pair<int, int>> vi;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    vi.push_back({a, b});
  }
  for (int i = 1; i < 1000; i++) {
    string s = to_string(i);
    if ((int)s.size() != n) continue;
    bool can = true;
    for (int j = 0; j < m; j++) {
      if (s[vi[j].first] != (char)vi[j].second + '0') {
        can = false;
      }
    }
    if (can) return cout << s, 0;
  }
  cout << -1;
  return 0;
}
