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

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

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

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

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

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

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

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

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