#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
void swap(long long int &a, long long int &b) {
  long long int t = a;
  a = b;
  b = t;
}
long long int min(long long int a, long long int b) {
  if (a < b) return a;
  return b;
}
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int pow(long long int a, long long int b) {
  a %= mod;
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return ans;
}
int main() {
  long long int n;
  cin >> n;
  long long int m;
  cin >> m;
  vector<long long int> a(n + 1, -1);
  long long int pos, dig, flg = 0;
  for (int i = 0; i < m; i++) {
    cin >> pos >> dig;
    if (a[pos] != -1) {
      if (a[pos] != dig) {
        flg = 1;
      }
    }
    a[pos] = dig;
  }
  if (flg == 1) {
    cout << "-1";
    return 0;
  }
  if (n == 1) {
    cout << a[1];
    return 0;
  }
  long long int prev = -1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0 && prev == -1) {
      flg = 1;
    }
    if (a[i] == -1) {
      if (prev == -1) {
        a[i] = 1;
        prev = 1;
      } else
        a[i] = 0;
    } else {
      if (prev == -1) prev = 1;
    }
  }
  if (flg) {
    cout << "-1";
  } else {
    for (int i = 1; i < a.size(); i++) cout << a[i];
  }
}
