def get_negative_nonnegative_lists(L):
'''(list of list of int) -> tuple of (list of int, list of int)
Return a tuple where the first item is a list of the negative ints in the
inner lists of L and the second item is a list of the non-negative ints
in those inner lists.
Precondition: the number of rows in L is the same as the number of
columns.
>>> get_negative_nonnegative_lists([[-1, 3, 5], [2, -4, 5], [4, 0, 8]])
([-1, -4], [3, 5, 2, 5, 4, 0, 8])
'''
nonneg = []
neg = []
for row in range(len(L)):
for col in range(len(L)):
val = L[row][col]
if val < 0:
neg.append(val)
else:
nonneg.append(val)
return (neg, nonneg)
ZGVmIGdldF9uZWdhdGl2ZV9ub25uZWdhdGl2ZV9saXN0cyhMKToKICAgICcnJyhsaXN0IG9mIGxpc3Qgb2YgaW50KSAtPiB0dXBsZSBvZiAobGlzdCBvZiBpbnQsIGxpc3Qgb2YgaW50KQoKICAgIFJldHVybiBhIHR1cGxlIHdoZXJlIHRoZSBmaXJzdCBpdGVtIGlzIGEgbGlzdCBvZiB0aGUgbmVnYXRpdmUgaW50cyBpbiB0aGUKICAgIGlubmVyIGxpc3RzIG9mIEwgYW5kIHRoZSBzZWNvbmQgaXRlbSBpcyBhIGxpc3Qgb2YgdGhlIG5vbi1uZWdhdGl2ZSBpbnRzCiAgICBpbiB0aG9zZSBpbm5lciBsaXN0cy4KCiAgICBQcmVjb25kaXRpb246IHRoZSBudW1iZXIgb2Ygcm93cyBpbiBMIGlzIHRoZSBzYW1lIGFzIHRoZSBudW1iZXIgb2YKICAgIGNvbHVtbnMuCgogICAgPj4+IGdldF9uZWdhdGl2ZV9ub25uZWdhdGl2ZV9saXN0cyhbWy0xLCAgMywgIDVdLCBbMiwgIC00LCAgNV0sIFs0LCAgMCwgIDhdXSkKICAgIChbLTEsIC00XSwgWzMsIDUsIDIsIDUsIDQsIDAsIDhdKQogICAgJycnCgogICAgbm9ubmVnID0gW10KICAgIG5lZyA9IFtdCiAgICBmb3Igcm93IGluIHJhbmdlKGxlbihMKSk6CiAgICAgICAgZm9yIGNvbCBpbiByYW5nZShsZW4oTCkpOgogICAgICAgICAgICB2YWwgPSBMW3Jvd11bY29sXQogICAgICAgICAgICBpZiB2YWwgPCAwOgogICAgICAgICAgICAgICAgbmVnLmFwcGVuZCh2YWwpCiAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICBub25uZWcuYXBwZW5kKHZhbCkKCiAgICByZXR1cm4gKG5lZywgbm9ubmVnKQ==