increments input and output for each traversal