#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) a[i] = -1;
  int x, y, flag = 1;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    if (a[x] == -1 || a[x] == y)
      a[x] = y;
    else
      flag = 0;
  }
  if (a[0] == 0 && n != 1) flag = 0;
  if (flag) {
    for (int i = 0; i < n; i++) {
      if (a[i] == -1) {
        if (i == 0)
          cout << "1";
        else
          cout << "0";
      } else
        cout << a[i];
    }
    cout << "\n";
  } else
    cout << "-1\n";
  return 0;
}
