#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  short negative = 1;
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') negative = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  x *= negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
bool prime(int n) {
  if (n == 0 || n == 1) return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
const long long power(int n, int k) {
  long long t = 1;
  for (int i = 0; i < (int)(k); i++) t *= n;
  return t;
}
const string turn2(int n) {
  string s = "";
  while (n != 0) {
    s += (char)(n % 2 + '0');
    n /= 2;
  }
  reverse(s.begin(), s.end());
  return s;
}
const string turn16(int n) {
  string s = "";
  while (n != 0) {
    if (n % 16 > 9)
      s += (char)('A' + n % 16 - 10);
    else
      s += (char)('0' + n % 16);
    n /= 16;
  }
  reverse(s.begin(), s.end());
  return s;
}
const long long quickpower(int n, int k) {
  if (k == 1) return n;
  if (k % 2 == 1)
    return n * quickpower(n, k / 2) * quickpower(n, k / 2);
  else
    return quickpower(n, k / 2) * (quickpower(n, k / 2));
}
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
char s[4];
int a[10], b[10];
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1 && m == 0) {
    cout << 0 << endl;
    return 0;
  }
  s[0] = '1';
  for (int i = 1; i < n; i++) {
    s[i] = '0';
  }
  for (int i = 0; i < (int)(m); i++) {
    cin >> a[i] >> b[i];
    s[a[i] - 1] = (char)(b[i] + '0');
  }
  for (int i = 0; i < (int)(m); i++) {
    for (int j = 0; j < (int)(m); j++) {
      if (i == j) continue;
      if (a[i] == a[j] && b[i] != b[j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  bool f = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (s[i] != '0') f = 1;
  }
  if (!f && n != 1) {
    cout << -1 << endl;
    return 0;
  }
  string now = "";
  for (int i = 0; i < (int)(n); i++) {
    if (s[i] != '0') {
      for (int j = i; j < n; j++) {
        now += s[j];
      }
      break;
    }
  }
  cout << now << endl;
  return 0;
}
