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

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

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

c = A("c")
b = B("b")
i = C("i")
n = C("n")
d = A("d")
m = B("m")
f = A("f")
l = B("l")

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

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

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

c = A("c")
b = B("b")
i = C("i")
n = C("n")
d = A("d")
m = B("m")
f = A("f")
l = B("l")

c.v = f
c.u = n
c.q = d
b.s = l
i.w = l
i.r = c
n.w = l
n.r = f
d.v = c
d.u = n
d.q = f
m.s = l
f.v = d
f.u = n
f.q = c
l.s = m
assert d.v.q.q.txt == "f"