SELECT
DISTINCT
    i1.key,
    i2.key,
    i1.subkey
FROM plato.Input AS i1 JOIN plato.Input AS i2 on i1.key == i2.subkey
ORDER BY i1.key, i2.key, i1.subkey
;
