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

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

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

l = A("l")
i = B("i")
f = C("f")
g = A("g")
a = B("a")
c = C("c")
d = B("d")
m = C("m")
h = A("h")
k = C("k")

l.w = c
l.q = d
i.r = l
i.w = d
i.v = h
f.v = c
g.w = k
g.q = i
a.r = g
a.v = g
a.w = d
c.v = f
d.r = h
d.w = a
d.v = g
m.v = k
h.w = f
h.q = d
k.v = f
assert a.r.w.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.q: B = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
f = C("f")
g = A("g")
a = B("a")
c = C("c")
d = B("d")
m = C("m")
h = A("h")
k = C("k")

l.w = c
l.q = d
i.r = l
i.w = d
i.v = h
f.v = c
g.w = k
g.q = i
a.r = g
a.v = g
a.w = d
c.v = f
d.r = h
d.w = a
d.v = g
m.v = k
h.w = f
h.q = d
k.v = f
assert a.r.w.v.v.v.v.v.txt == "f"