#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxself(T &a, T &b) {
  a = max(a, b);
};
template <typename T>
void minself(T &a, T &b) {
  a = min(a, b);
};
const long long LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int digit[10];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  memset(digit, -1, sizeof digit);
  int idx, x;
  bool invalid = false;
  for (int i = 0; i < (int)(m); ++i) {
    scanf("%d %d", &idx, &x);
    digit[idx] = x;
  }
  int cnt = 0;
  for (int i = 1; i <= (int)(n); ++i) {
    if (digit[i] == -1) cnt++;
  }
  if (cnt >= 2) invalid = true;
  if (invalid)
    puts("-1");
  else {
    for (int i = 1; i <= (int)(n); ++i) {
      if (digit[i] == -1 and i == 1)
        digit[i] = 1;
      else if (digit[i] == -1)
        digit[i] = 0;
      printf("%d", digit[i]);
    }
    putchar('\n');
  }
  return 0;
}
