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

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

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

n = A("n")
h = B("h")
d = C("d")
c = C("c")
j = C("j")

n.q = h
n.s = j
h.v = c
d.q = n
d.o = h
d.u = h
c.q = n
c.o = h
c.u = h
j.q = n
j.o = h
j.u = h
assert h.v.o.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: C = None
        self.txt = txt

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

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

n = A("n")
h = B("h")
d = C("d")
c = C("c")
j = C("j")

n.q = h
n.s = j
h.v = c
d.q = n
d.o = h
d.u = h
c.q = n
c.o = h
c.u = h
j.q = n
j.o = h
j.u = h
assert h.v.o.v.o.v.txt == "c"