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

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

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

i = A("i")
f = B("f")
m = C("m")
g = C("g")
j = B("j")

i.v = j
i.w = j
f.t = i
f.z = j
m.q = j
m.v = g
m.o = f
g.q = j
g.v = m
g.o = f
j.t = i
j.z = f
assert m.q.t.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.w: B = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
m = C("m")
g = C("g")
j = B("j")

i.v = j
i.w = j
f.t = i
f.z = j
m.q = j
m.v = g
m.o = f
g.q = j
g.v = m
g.o = f
j.t = i
j.z = f
assert m.q.t.w.t.w.txt == "j"