#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int N = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
inline long long read() {
  long long x = 0;
  int f = 1, c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
  return x * f;
}
string s;
int n, m;
int main() {
  n = read();
  m = read();
  for (int(i) = 0; (i) < (int)(n); i++) s.push_back('-');
  for (int(i) = 0; (i) < (int)(m); i++) {
    int x = read() - 1, y = read();
    if (s[x] != '-' && s[x] != y + '0') {
      puts("-1");
      return 0;
    }
    s[x] = y + '0';
  }
  if (s[0] == '0') {
    puts("-1");
    return 0;
  }
  if (s[0] == '-') s[0] = '1';
  for (int(i) = 0; (i) < (int)(n); i++)
    if (s[i] == '-') s[i] = '0';
  cout << s << endl;
  return 0;
}
