tries implementation