#include <bits/stdc++.h>
using namespace std;
long long int modF = 1e9 + 7;
long long int INF = 1e11;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> second(m);
  vector<int> a(n, -1);
  for (int i = 0; i < m; i++) {
    int h;
    cin >> second[i] >> h;
    if (second[i] == 1 && h == 0 && n != 1) {
      cout << -1 << "\n";
      return;
    }
    if (a[second[i] - 1] == -1 || a[second[i] - 1] == h)
      a[second[i] - 1] = h;
    else {
      cout << -1 << "\n";
      return;
    }
  }
  int h = 1;
  if (n == 1) h = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == -1) {
      cout << h;
    } else {
      cout << a[i];
      h = 0;
    }
  }
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(10);
  solve();
  return 0;
}
