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

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

g = A("g")
k = B("k")
h = A("h")
d = A("d")
e = A("e")

g.x = k
g.u = k
k.t = h
h.x = k
h.u = k
d.x = k
d.u = k
e.x = k
e.u = k
assert e.u.t.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.u: B = None
        self.txt = txt

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

g = A("g")
k = B("k")
h = A("h")
d = A("d")
e = A("e")

g.x = k
g.u = k
k.t = h
h.x = k
h.u = k
d.x = k
d.u = k
e.x = k
e.u = k
assert e.u.t.u.t.u.txt == "k"