#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
inline void init() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  int N, M;
  cin >> N >> M;
  map<int, int> mp;
  for (int i = (int)(0); i < (int)(M); ++i) {
    int a, b;
    cin >> a >> b;
    if (mp.count(a)) {
      if (mp[a] != b) {
        cout << -1 << "\n";
        return 0;
      }
    } else
      mp[a] = b;
  }
  vector<int> s(N, 0);
  s[0] = 1;
  for (auto p : mp) {
    s[p.first - 1] = p.second;
  }
  if (s[0] == 0 && N != 1) {
    cout << -1 << "\n";
    return 0;
  }
  for (int i = (int)(0); i < (int)(N); ++i) {
    cout << s[i];
    if (i == N - 1) cout << "\n";
  }
  return 0;
}
