#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vpii(m);
  for (int i = 0; i < int(m); i++) {
    cin >> vpii[i].first >> vpii[i].second;
  }
  vector<int> a(n, -1);
  for (int i = 0; i < int(m); i++) {
    if (a[vpii[i].first - 1] != -1 && a[vpii[i].first - 1] != vpii[i].second) {
      cout << -1 << endl;
      return 0;
    }
    if (vpii[i].first == 1 && vpii[i].second == 0) {
      cout << -1 << endl;
      return 0;
    }
    a[vpii[i].first - 1] = vpii[i].second;
  }
  for (int i = 0; i < int(n); i++)
    if (a[i] == -1) a[i] = 0;
  if (a[0] == 0) a[0] = 1;
  for (int i = 0; i < int(n); i++) cout << a[i];
  cout << endl;
}
