class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

n = A("n")
l = B("l")
a = A("a")
k = A("k")

n.u = k
l.p = a
a.u = n
k.u = a
assert a.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

n = A("n")
l = B("l")
a = A("a")
k = A("k")

n.u = k
l.p = a
a.u = n
k.u = a
assert a.u.u.u.txt == "a"