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

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

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

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

a.q = m
a.r = b
i.v = b
i.q = c
e.w = n
e.q = n
e.u = a
n.v = b
n.q = c
b.w = c
b.q = c
b.u = a
c.v = e
c.q = n
m.q = a
m.r = e
assert b.q.q.v.u.r.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: C = None
        self.txt = txt

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

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

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

a.q = m
a.r = b
i.v = b
i.q = c
e.w = n
e.q = n
e.u = a
n.v = b
n.q = c
b.w = c
b.q = c
b.u = a
c.v = e
c.q = n
m.q = a
m.r = e
assert b.q.q.v.u.r.q.q.txt == "n"