#include <bits/stdc++.h>
using ll = long long;
constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);
using namespace std;
void scans(string& str) {
  char c;
  str = "";
  scanf("%c", &c);
  if (c == '\n') scanf("%c", &c);
  while (c != '\n' && c != -1 && c != ' ') {
    str += c;
    scanf("%c", &c);
  }
}
void scanc(char& str) {
  char c;
  scanf("%c", &c);
  if (c == -1) return;
  while (c == '\n') {
    scanf("%c", &c);
  }
  str = c;
}
double acot(double x) { return PI / 2 - atan(x); }
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll number1, ll number2) {
  return number1 / gcd(number1, number2) * number2;
}
ll LSB(ll n) { return (n & (-n)); }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  fill((a).begin(), (a).end(), -1);
  int s, t;
  for (int i = 0; i < (m); ++i) {
    scanf("%d%d", &s, &t);
    --s;
    if (a[s] != -1 && a[s] != t) {
      printf("-1\n");
      return 0;
    } else {
      a[s] = t;
    }
  }
  string ans = "";
  for (int i = 0; i < (n); ++i) {
    if (a[i] == -1) {
      if (i == 0)
        ans.push_back('1');
      else
        ans.push_back('0');
    } else {
      ans.push_back(a[i] + '0');
    }
  }
  if (ans[0] == '0') {
    printf("-1\n");
    return 0;
  }
  if (m == 0 && n == 1) ans = "0";
  printf("%s\n", ans.c_str());
  return 0;
}
