2nd problem solved in Python.