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

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

class C:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

i = A("i")
b = B("b")
f = C("f")
k = B("k")
h = A("h")
e = A("e")
m = A("m")
j = C("j")

i.v = k
i.w = k
i.z = f
b.v = k
f.o = j
k.v = b
h.v = k
h.w = k
h.z = j
e.v = b
e.w = k
e.z = f
m.v = b
m.w = k
m.z = f
j.o = f
assert k.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.w: B = None
        self.z: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

i = A("i")
b = B("b")
f = C("f")
k = B("k")
h = A("h")
e = A("e")
m = A("m")
j = C("j")

i.v = k
i.w = k
i.z = f
b.v = k
f.o = j
k.v = b
h.v = k
h.w = k
h.z = j
e.v = b
e.w = k
e.z = f
m.v = b
m.w = k
m.z = f
j.o = f
assert k.v.v.v.v.v.v.txt == "k"