#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0};
const int dy[] = {0, -1};
const int MOD = 1000 * 1000 * 1000 + 7;
const int N = 1000 * 1000 + 5;
const int MAXN = 1000000;
const int INF = INT_MAX;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> res(n, -1);
  for (int &x : res) x = -1;
  vector<array<int, 2>> v(m);
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    --s;
    v[i][0] = s, v[i][1] = c;
    res[s] = c;
  }
  for (int i = 0; i < n; ++i) {
    if (i == 0 and res[i] == -1)
      res[i] = 1;
    else if (res[i] == -1)
      res[i] = 0;
  }
  bool ok = true;
  for (auto x : v) {
    int s = x[0], c = x[1];
    if (res[s] != c) {
      ok = false;
      break;
    }
  }
  int all = ((res[0] == 0 and n != 1) or m == 0);
  if (ok and !all) {
    for (auto x : res) cout << x;
  } else
    cout << "-1";
  cout << "\n";
  return 0;
}
