#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double EPS = 1e-9;
const long long MOD = 1e9 + 7;
const int INF = 1e9;
long long addMod(long long a, long long b) {
  if (a + b >= MOD) return a + b - MOD;
  return a + b;
}
long long mulMod(long long a, long long b) { return (a * b) % MOD; }
long long fast(long long a, long long b) {
  if (b == 0) return 1;
  long long tmp = fast(a, b / 2);
  tmp = mulMod(tmp, tmp);
  if (b % 2 == 1) tmp = mulMod(tmp, a);
  return tmp;
}
long long GCD(long long a, long long b) {
  if (a > b) return GCD(b, a);
  if (a == 0) return b;
  return GCD(b % a, a);
}
template <typename T>
T getnum() {
  int sign = 1;
  T ret = 0;
  char c;
  do {
    c = getchar();
  } while (c == ' ' || c == '\n');
  if (c == '-')
    sign = -1;
  else
    ret = c - '0';
  while (1) {
    c = getchar();
    if (c < '0' || c > '9') break;
    ret = 10 * ret + c - '0';
  }
  return sign * ret;
}
inline void ini(int& x) { x = getnum<int>(); }
const int N = 1e5;
int num[4];
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(num, -1, sizeof num);
  int n, m;
  cin >> n >> m;
  bool flag = true;
  for (int i = 0; i <= (int)m - 1; i += 1) {
    int a, b;
    cin >> a >> b;
    if (num[a] == -1 || num[a] == b)
      num[a] = b;
    else
      flag = false;
  }
  if (num[1] == 0) flag = false;
  if (!flag)
    cout << -1 << endl;
  else {
    for (int i = 1; i <= n; i += 1) {
      if (num[i] == -1) {
        if (i == 1)
          num[i] = 1;
        else
          num[i] = 0;
      }
      cout << num[i];
    }
    cout << endl;
  }
  return 0;
}
