const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
const n = Number(await readline());
const arr = (await readline()).split(" ").map(Number);
const inMap = new Map();
const outMap = new Map();
for (let i = 0; i < arr.length; i += 2) {
const a = arr[i];
const b = arr[i + 1];
if (!inMap.has(a)) inMap.set(a, 0);
if (!inMap.has(b)) inMap.set(b, 0);
if (!outMap.has(a)) outMap.set(a, 0);
if (!outMap.has(b)) outMap.set(b, 0);
inMap.set(b, inMap.get(b) + 1);
outMap.set(a, outMap.get(a) + 1);
}
const startNode = [];
const endNode = [];
if (![...inMap.values()].includes(0)) return console.log(-1);
if (![...outMap.values()].includes(0)) return console.log(-1);
inMap.forEach((val, key) => {
if (val == 0) startNode.push(key);
});
outMap.forEach((val, key) => {
if (val == 0) endNode.push(key);
});
endNode.sort((a, b) => b - a);
console.log(startNode.join(" ") + " " + endNode.join(" "));
})();