function Main(input) {
  lines = input.split('\n')
  n = lines[0].split(' ')[0] * 1
  m = lines[0].split(' ')[1] * 1
  l = 0
  r = n
  for (i = 1; i < lines.length; i++) {
    ls = lines[i].split(' ')[0] * 1 
    rs = lines[i].split(' ')[1] * 1
    if (l < ls) {
        l = ls
    }
    if (r > rs) {
        r = rs
    }
  }
  console.log(l, r, r - l < 0 ? 0 : r - l + 1)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
