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

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

a = A("a")
j = B("j")
c = A("c")
e = A("e")
g = B("g")
m = A("m")
i = B("i")
f = A("f")

a.z = g
a.s = g
j.s = f
c.z = i
c.s = i
e.z = g
e.s = j
g.s = c
m.z = i
m.s = i
i.s = c
f.z = g
f.s = i
assert c.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: B = None
        self.txt = txt

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

a = A("a")
j = B("j")
c = A("c")
e = A("e")
g = B("g")
m = A("m")
i = B("i")
f = A("f")

a.z = g
a.s = g
j.s = f
c.z = i
c.s = i
e.z = g
e.s = j
g.s = c
m.z = i
m.s = i
i.s = c
f.z = g
f.s = i
assert c.s.s.s.s.txt == "c"