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

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

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

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

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

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

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