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

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

b = A("b")
j = B("j")
a = B("a")
f = A("f")

b.u = j
j.t = f
j.z = a
a.t = f
a.z = j
f.u = j
assert f.u.z.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

b = A("b")
j = B("j")
a = B("a")
f = A("f")

b.u = j
j.t = f
j.z = a
a.t = f
a.z = j
f.u = j
assert f.u.z.t.u.txt == "j"