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

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: A = None
        self.p: A = None
        self.txt = txt

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

m = A("m")
n = B("n")
e = C("e")
h = C("h")
i = A("i")
b = C("b")
j = A("j")
a = C("a")

m.q = e
m.s = j
n.u = m
n.r = j
n.p = j
e.s = n
h.s = n
i.q = h
i.s = m
b.s = n
j.q = b
j.s = m
a.s = n
assert i.q.s.u.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: A = None
        self.p: A = None
        self.txt = txt

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

m = A("m")
n = B("n")
e = C("e")
h = C("h")
i = A("i")
b = C("b")
j = A("j")
a = C("a")

m.q = e
m.s = j
n.u = m
n.r = j
n.p = j
e.s = n
h.s = n
i.q = h
i.s = m
b.s = n
j.q = b
j.s = m
a.s = n
assert i.q.s.u.s.q.txt == "b"