#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void testcase() {
  int n, m;
  cin >> n >> m;
  string res = "";
  for (int i = 0; i <= (n - 1); ++i) res += "-";
  while (m--) {
    int s, c;
    cin >> s >> c;
    s--;
    char ch = (c + 48);
    if (res[s] == '-' || res[s] == ch) {
      res[s] = ch;
    } else {
      cout << "-1\n";
      return;
    }
  }
  for (int i = 0; i <= (n - 1); ++i)
    if (res[i] == '-') res[i] = (i == 0 ? '1' : '0');
  if (n > 1 && res[0] == '0') {
    cout << "-1\n";
    return;
  }
  cout << res << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  if (0) cin >> t;
  while (t--) {
    testcase();
  }
  return 0;
}
