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

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

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

l = A("l")
f = B("f")
a = C("a")
i = A("i")
d = A("d")
j = B("j")
h = B("h")
b = A("b")

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

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

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

l = A("l")
f = B("f")
a = C("a")
i = A("i")
d = A("d")
j = B("j")
h = B("h")
b = A("b")

l.w = a
l.r = f
f.s = a
f.v = a
a.q = f
i.w = a
i.r = j
d.w = a
d.r = h
j.s = a
j.v = a
h.s = a
h.v = a
b.w = a
b.r = h
assert f.s.q.v.q.v.txt == "a"