#include <bits/stdc++.h>
using namespace std;
int keta(long long x) {
  if (x < 10) {
    return 1;
  } else {
    return keta(x / 10) + 1;
  }
}
int keta_wa(long long x) {
  if (x < 10) {
    return x;
  } else {
    return keta_wa(x / 10) + x % 10;
  }
}
int ctoi(char c) { return ((c >= '0' && c <= '9') ? c - '0' : 0); }
int __stoi(string s) { return atoi(s.c_str()); }
long long sum(long long a[], long long N) { return accumulate(a, a + N, 0LL); }
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  return b ? gcd(b, a % b) : a;
}
long long lcm(long long a, long long b) {
  if (a < b) {
    swap(a, b);
  }
  return a / gcd(a, b) * b;
}
template <class T>
void chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
}
template <class T>
void chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  int a[N];
  ;
  for (int i = 0, i_len = ((N)); i < i_len; ++i) {
    (a)[i] = (-1);
  };
  bool ok = true;
  for (int count = 0, count_len = (M); count < count_len; ++count) {
    int s, c;
    cin >> s >> c;
    --s;
    if (a[s] == -1) {
      a[s] = c;
    } else if (a[s] != c) {
      ok = false;
    }
  }
  if (ok) {
    ok = (a[0] != 0);
  }
  if (ok) {
    for (int i = 0, i_len = (N); i < i_len; ++i) {
      if (a[i] == -1) {
        if (i == 0 && N > 1) {
          a[i] = 1;
        } else {
          a[i] = 0;
        }
      }
    }
    for (int i = 0, i_len = (N); i < i_len; ++i) {
      printf("%d", a[i]);
    }
    printf("\n");
  } else {
    printf("-1\n");
  }
}
