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

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

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

j = A("j")
d = B("d")
i = C("i")
a = C("a")
k = B("k")
m = B("m")
e = A("e")

j.t = k
j.u = i
j.q = i
d.o = k
d.v = k
i.q = j
i.r = a
a.q = j
a.r = i
k.o = d
k.v = d
m.o = k
m.v = d
e.t = m
e.u = i
e.q = a
assert m.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.u: C = None
        self.q: C = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
i = C("i")
a = C("a")
k = B("k")
m = B("m")
e = A("e")

j.t = k
j.u = i
j.q = i
d.o = k
d.v = k
i.q = j
i.r = a
a.q = j
a.r = i
k.o = d
k.v = d
m.o = k
m.v = d
e.t = m
e.u = i
e.q = a
assert m.v.o.v.txt == "d"