#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n, long long m) { return m ? gcd(m, n % m) : n; }
long long lcm(long long n, long long m) { return n / gcd(n, m) * m; }
struct debugger {
  static void call(string::iterator it, string::iterator ed) {}
  template <typename T, typename... aT>
  static void call(string::iterator it, string::iterator ed, T a, aT... rest) {
    string b;
    for (; *it != ','; ++it)
      if (*it != ' ') b += *it;
    cout << b << "=" << a << " ";
    call(++it, ed, rest...);
  }
};
void solve() {
  int n, m;
  scanf("%d", &n), scanf("%d", &m);
  vector<int> number(n + 1);
  while (m--) {
    int a, b;
    scanf("%d", &a), scanf("%d", &b);
    number[a] = b;
  }
  if (n > 1 && number[1] == 0) {
    printf("%d\n", -1);
  } else {
    for (int i = 1; i < n + 1; i++) {
      printf("%d", number[i]);
    }
    printf("\n");
  }
}
int main() {
  solve();
  cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
  ;
  return 0;
}
