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

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

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

l = A("l")
c = B("c")
e = C("e")
i = A("i")
a = C("a")
m = B("m")
d = B("d")

l.v = e
l.y = e
c.q = e
e.y = i
e.r = i
i.v = a
i.y = e
a.y = i
a.r = l
m.q = e
d.q = e
assert c.q.y.v.r.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.y: C = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
e = C("e")
i = A("i")
a = C("a")
m = B("m")
d = B("d")

l.v = e
l.y = e
c.q = e
e.y = i
e.r = i
i.v = a
i.y = e
a.y = i
a.r = l
m.q = e
d.q = e
assert c.q.y.v.r.v.y.txt == "i"