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

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

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

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

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

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

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

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

n.s = b
n.p = m
a.q = b
a.y = n
a.r = n
j.u = m
j.p = n
j.v = b
b.u = m
b.p = n
b.v = j
m.q = b
m.y = n
m.r = n
assert j.p.p.q.u.q.txt == "b"