Encoding undirected and semi-directed binary phylogenetic networks by quarnets