#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, i, s, c, flag = 0, flag2 = 0;
  cin >> n >> m;
  vector<int> A(n, -1);
  for (i = 0; i < m; i++) {
    cin >> s >> c;
    if (A[s - 1] == c || A[s - 1] == -1)
      A[s - 1] = c;
    else
      flag = 1;
    if (c != 0) flag2 = 1;
  }
  if (!flag2) {
    cout << "0\n";
    return;
  }
  if (n > 1 && A[0] == 0)
    flag = 1;
  else {
    for (i = 0; i < n; i++) {
      if (A[i] == -1 && i == 0)
        A[i] = 1;
      else if (A[i] == -1)
        A[i] = 0;
    }
  }
  if (flag)
    cout << "-1";
  else
    for (auto a : A) cout << a;
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
