def dfs!(lines, v)
  if lines.size == v
    return
  end
  child = lines.select{|line| line[0] == lines[v][0]}.size
  if child % 2 == 1
   lines[v].rotate!
  end
  dfs!(lines, v + 1)
end


N, M = gets.split.map(&:to_i)
lines = []
M.times do
  lines << gets.split.map(&:to_i)
end

if lines.size % 2 != 0
  puts '-1'
end

dfs!(lines, 0)

puts lines.map{|line| line.join(' ')}.join("\n")
