Y and Z given for inputs P