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

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

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

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

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

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

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

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

a.v = k
i.o = k
i.x = b
h.w = j
h.t = a
h.z = i
j.w = h
j.t = a
j.z = i
f.o = k
f.x = h
b.w = h
b.t = a
b.z = f
k.o = i
k.x = h
assert i.o.x.w.w.w.txt == "j"