#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n + 1, -1);
  map<int, int> mp;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (mp.find(s) != mp.end() && mp[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    mp[s] = c;
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    auto s = it->first;
    auto c = it->second;
    ans[s] = c;
  }
  if (ans[1] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] == -1) {
      cout << 1;
    } else {
      cout << ans[i];
    }
  }
  cout << endl;
  return 0;
}
