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

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

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

i = A("i")
a = B("a")
b = C("b")
m = A("m")
d = B("d")
h = C("h")

i.v = a
a.q = b
b.o = h
b.x = a
b.u = d
m.v = a
d.q = h
h.o = b
h.x = a
h.u = d
assert i.v.q.o.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

i = A("i")
a = B("a")
b = C("b")
m = A("m")
d = B("d")
h = C("h")

i.v = a
a.q = b
b.o = h
b.x = a
b.u = d
m.v = a
d.q = h
h.o = b
h.x = a
h.u = d
assert i.v.q.o.u.q.txt == "h"