#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << ' ' << *it << " = " << a;
  err(++it, args...);
}
const int N = 1e5 + 1, M = 5e5 + 1, OO = 0x3f3f3f3f, MOD = 1e9 + 7;
int arr[4] = {-1, -1, -1, -1};
int main() {
  int n, m;
  bool f = 1;
  scanf("%d%d", &n, &m);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (!~arr[x] || arr[x] == y)
      arr[x] = y;
    else
      f = 0;
  }
  if (!f)
    puts("-1");
  else {
    if (!arr[1] && n > 1)
      puts("-1");
    else {
      if (!~arr[1])
        puts("1");
      else
        printf("%d", arr[1]);
      for (int i = 2; i <= n; ++i) {
        if (!~arr[i])
          printf("0");
        else
          printf("%d", arr[i]);
      }
      puts("");
    }
  }
  return 0;
}
