#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"
using namespace std;
const long long MOD = 1e+9 + 7;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const long long MAXN = 1e+6 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tc = 1;
  while (tc--) {
    int i, j, n, m;
    cin >> n >> m;
    vector<int> num(n, -1);
    for (i = 0; i < m; ++i) {
      int pos, aux;
      cin >> pos >> aux;
      --pos;
      if (num[pos] >= 0 && num[pos] != aux)
        num[pos] = -2;
      else if (num[pos] != -2)
        num[pos] = aux;
    }
    for (i = 0; i < num.size(); ++i)
      if (num[i] == -2) break;
    if (num[0] == 0) i = num.size() - 1;
    if (i < num.size()) {
      cout << "-1\n";
      continue;
    }
    if (num[0] == -1) num[0] = 1;
    for (i = 1; i < num.size(); ++i)
      if (num[i] == -1) num[i] = 0;
    for (auto& a : num) cout << a;
    cout << '\n';
  }
  return 0;
}
