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

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

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

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

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

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

l.x = k
g.u = a
k.u = g
a.u = g
assert k.u.u.u.u.txt == "a"