<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _replace_nan(a, val):
 """ replace nan in a by val, and returns the replaced array and the nan position """

    mask = isnull(a)
    return where_method(val, mask, a), mask