Updated for Homework #18b; implemented LR and UD usage