class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: A = None
        self.s: A = None
        self.txt = txt

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

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

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

e.r = n
e.v = n
e.s = n
c.v = m
c.q = m
i.v = c
m.v = c
m.q = c
n.r = e
n.v = e
n.s = e
f.v = m
assert m.q.q.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: A = None
        self.s: A = None
        self.txt = txt

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

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

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

e.r = n
e.v = n
e.s = n
c.v = m
c.q = m
i.v = c
m.v = c
m.q = c
n.r = e
n.v = e
n.s = e
f.v = m
assert m.q.q.v.v.v.v.txt == "m"