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

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

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

b = A("b")
f = B("f")
n = C("n")
m = B("m")
d = C("d")
k = B("k")
l = C("l")
e = A("e")
i = A("i")

b.v = f
f.w = i
n.z = b
n.q = d
m.w = b
d.z = i
d.q = l
k.w = i
l.z = i
l.q = n
e.v = m
i.v = k
assert m.w.v.w.v.w.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
n = C("n")
m = B("m")
d = C("d")
k = B("k")
l = C("l")
e = A("e")
i = A("i")

b.v = f
f.w = i
n.z = b
n.q = d
m.w = b
d.z = i
d.q = l
k.w = i
l.z = i
l.q = n
e.v = m
i.v = k
assert m.w.v.w.v.w.v.w.txt == "i"