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

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

g = A("g")
a = B("a")
i = A("i")
f = A("f")
e = B("e")
b = B("b")

g.t = i
g.s = i
a.u = e
a.z = g
i.t = g
i.s = f
f.t = i
f.s = i
e.u = b
e.z = g
b.u = e
b.z = f
assert a.z.t.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.s: A = None
        self.txt = txt

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

g = A("g")
a = B("a")
i = A("i")
f = A("f")
e = B("e")
b = B("b")

g.t = i
g.s = i
a.u = e
a.z = g
i.t = g
i.s = f
f.t = i
f.s = i
e.u = b
e.z = g
b.u = e
b.z = f
assert a.z.t.t.s.txt == "i"