#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
int32_t main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  string ans;
  for (int i = 0; i < n; ++i) ans.push_back('$');
  for (int i = 0; i < m; ++i) {
    int j, x;
    cin >> j >> x;
    j -= 1;
    if (ans[j] != '$' and int(ans[j] - '0') != x) {
      cout << -1 << endl;
      return 0;
    }
    ans[j] = x + '0';
  }
  if (ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  for (auto &x : ans)
    if (x == '$') x = '1';
  cout << ans << endl;
}
