A succinct data structure for self-indexing ternary relations