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

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

g = A("g")
l = B("l")
c = B("c")
n = B("n")
d = A("d")
k = A("k")
a = A("a")
i = B("i")
h = A("h")
b = A("b")

g.w = n
l.z = h
c.z = d
n.z = b
d.w = i
k.w = n
a.w = n
i.z = b
h.w = c
b.w = c
assert n.z.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

g = A("g")
l = B("l")
c = B("c")
n = B("n")
d = A("d")
k = A("k")
a = A("a")
i = B("i")
h = A("h")
b = A("b")

g.w = n
l.z = h
c.z = d
n.z = b
d.w = i
k.w = n
a.w = n
i.z = b
h.w = c
b.w = c
assert n.z.w.z.w.txt == "i"