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

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

g = A("g")
k = B("k")
m = B("m")
a = B("a")
d = B("d")
f = B("f")
c = B("c")
b = A("b")
i = B("i")

g.w = b
k.v = g
k.z = a
m.v = b
m.z = k
a.v = b
a.z = f
d.v = g
d.z = k
f.v = b
f.z = a
c.v = g
c.z = a
b.w = g
i.v = g
i.z = k
assert i.v.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

g = A("g")
k = B("k")
m = B("m")
a = B("a")
d = B("d")
f = B("f")
c = B("c")
b = A("b")
i = B("i")

g.w = b
k.v = g
k.z = a
m.v = b
m.z = k
a.v = b
a.z = f
d.v = g
d.z = k
f.v = b
f.z = a
c.v = g
c.z = a
b.w = g
i.v = g
i.z = k
assert i.v.w.w.w.w.w.txt == "b"