#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans;
  vector<int> vis;
  vis.resize(n);
  ans.resize(n);
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    --s;
    if (s == 0 && c == 0 && n != 1) {
      cout << -1 << '\n';
      return 0;
    }
    if (vis[s] == 1 && ans[s] != c) {
      cout << -1 << '\n';
      return 0;
    }
    vis[s] = 1;
    ans[s] = c;
  }
  for (int i = 0; i < n; ++i) {
    if (vis[i] == 0) {
      ans[i] = 1;
    }
    cout << ans[i];
  }
  cout << '\n';
  return 0;
}
