#include <bits/stdc++.h>
using namespace std;
template <typename T>
void pop_front(std::vector<T> &v) {
  if (v.size() > 0) {
    v.erase(v.begin());
  }
}
template <typename R>
void pop_back(std::vector<R> &v) {
  if (v.size() > 0) {
    v.erase(v.begin() + v.size() - 1);
  }
}
bool isprime(long long int n) {
  if (n <= 1) return false;
  for (long long int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
vector<long long int> factors(long long int n) {
  vector<long long int> v;
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      if ((n / i) != i) v.push_back(n / i);
    }
  }
  return v;
}
long long int power(long long int a, long long int n) {
  long long int res = 1;
  while (1) {
    if (n % 2) {
      res = res * a;
      n--;
    }
    if (n == 0) break;
    a = a * a;
    n /= 2;
  }
  return res;
}
long long int ts(long long int arr[], int l, int r, int x) {
  while (l <= r) {
    long long int mid1 = l + (r - l) / 3;
    long long int mid2 = r - (r - l) / 3;
    if (arr[mid1] == x || arr[mid2] == x) return 1;
    if (x < arr[mid1])
      r = mid1 - 1;
    else if (x > arr[mid2])
      l = mid2 + 1;
    else {
      l = mid1 + 1;
      r = mid2 - 1;
    }
  }
  return -1;
}
int main() {
  auto start = chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int T = 1;
  while (T--) {
    long long int n, m;
    cin >> n >> m;
    vector<long long int> vec(n, -1);
    int flag = 0;
    while (m--) {
      long long int pos, val;
      cin >> pos >> val;
      pos--;
      if (vec[pos] != -1) {
        if (val != vec[pos]) {
          flag = 1;
          break;
        }
      }
      vec[pos] = val;
    }
    if (vec[0] == 0) flag = 1;
    if (vec[0] == -1) vec[0] = 1;
    for (long long int i = 1; i < n; i++)
      if (vec[i] == -1) vec[i] = 0;
    if (flag == 1)
      cout << -1 << "\n";
    else {
      for (auto x : vec) cout << x;
      cout << "\n";
    }
  }
  auto finish = chrono::high_resolution_clock::now();
  cerr << "Time elapsed: "
       << (chrono::duration<long double>(finish - start)).count() << "s\n";
  return 0;
}
