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

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

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

g = A("g")
i = B("i")
c = C("c")
d = C("d")
a = A("a")
f = A("f")
n = A("n")
m = B("m")
b = C("b")
j = C("j")

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

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

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

g = A("g")
i = B("i")
c = C("c")
d = C("d")
a = A("a")
f = A("f")
n = A("n")
m = B("m")
b = C("b")
j = C("j")

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