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

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

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

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

j.q = e
j.v = i
a.o = h
a.x = j
a.q = m
i.v = d
e.v = d
d.v = e
c.v = e
h.o = m
h.x = j
h.q = a
m.o = a
m.q = a
m.x = j
assert j.q.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: C = None
        self.txt = txt

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

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

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

j.q = e
j.v = i
a.o = h
a.x = j
a.q = m
i.v = d
e.v = d
d.v = e
c.v = e
h.o = m
h.x = j
h.q = a
m.o = a
m.q = a
m.x = j
assert j.q.v.v.v.v.v.txt == "d"