#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  map<int, int> dic;
  for (int i = 0; i < (int)(M); ++i) {
    int s, c;
    cin >> s >> c;
    if (dic.count(s)) {
      if (dic[s] != c) {
        cout << -1 << '\n';
        return 0;
      }
    } else {
      if (N != 1 && s == 1 && c == 0) {
        cout << -1 << '\n';
        return 0;
      }
      dic[s] = c;
    }
  }
  string ans = "";
  for (int i = 1; i <= N; ++i) {
    if (dic.count(i)) {
      ans += char(dic[i] + '0');
    } else {
      ans += '1';
    }
  }
  cout << ans << '\n';
}
