#include <bits/stdc++.h>
using namespace std;
double getTime() { return clock() / (double)CLOCKS_PER_SEC; }
void read(){};
template <typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}
void print(){};
template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (ans[x - 1]) {
      puts("-1");
      return 0;
    }
    ans[x - 1] = y;
  }
  for (int i = 0; i < n; i++) {
    if (ans[i]) continue;
    if (i == 0 and n == 1)
      ans[i] = 0;
    else if (i == 0)
      ans[i] = 1;
    else
      ans[i] = 0;
  }
  if (ans[0] == 0 and n != 1) {
    puts("-1");
    return 0;
  }
  for (auto x : ans) cout << x;
  puts("");
}
