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

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

i = A("i")
j = B("j")
f = B("f")
a = A("a")
l = B("l")
c = A("c")

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

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

i = A("i")
j = B("j")
f = B("f")
a = A("a")
l = B("l")
c = A("c")

i.s = j
i.w = c
j.z = c
j.y = f
f.z = c
f.y = j
a.s = j
a.w = c
l.z = i
l.y = j
c.s = j
c.w = a
assert l.y.y.z.w.s.z.txt == "c"