#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 50);
int main() {
  int n, m;
  cin >> n >> m;
  if (m == 0 && n > 1) {
    for (int i = 0; i < (n); i++) cout << 1;
    return 0;
  }
  if (m == 0 && n == 1) {
    cout << 0;
    return 0;
  }
  vector<pair<int, int> > sc(m);
  for (int i = 0; i < (m); i++) {
    cin >> sc[i].first >> sc[i].second;
  }
  int ok = 1;
  int a = sc[0].first;
  int b = sc[0].second;
  for (int i = 0; i < (m); i++) {
    if (sc[i].first == a && sc[i].second != b) ok = 0;
  }
  if (ok == 0) {
    cout << -1 << endl;
    return 0;
  }
  ok = 1;
  if (n > 1) {
    for (int i = 0; i < (m); i++) {
      if (sc[i].first == 1 && sc[i].second == 0) {
        ok = 0;
      }
    }
  }
  if (ok == 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    int f = 0;
    for (int j = 0; j < m; j++) {
      if (sc[j].first == i + 1) {
        ans.push_back(sc[j].second);
        f = 1;
        break;
      }
    }
    if (f == 0 && i == 0) ans.push_back(1);
    if (f == 0 && i != 0) ans.push_back(0);
  }
  for (int i = 0; i < (n); i++) cout << ans[i];
  return 0;
}
