#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
int main() {
  int n, m, k = 0;
  cin >> n >> m;
  vector<int> s(m), c(m), t(4, -1);
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    if (t[s[i]] == -1) {
      t[s[i]] = c[i];
    } else if (t[s[i]] != c[i])
      k = -1;
  }
  if (t[1] == 0 || k == -1) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i < n + 1; i++) {
    if (t[i] != -1)
      cout << t[i];
    else if (i == 1 && t[i] == -1)
      cout << 1;
    else
      cout << 0;
  }
  cout << endl;
  return 0;
}
