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

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

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

d = A("d")
k = B("k")
e = C("e")
l = C("l")
b = B("b")
a = A("a")
f = A("f")

d.q = k
d.x = b
k.w = b
k.v = l
e.q = l
e.s = b
l.q = e
l.s = k
b.w = k
b.v = e
a.q = b
a.x = k
f.q = b
f.x = b
assert d.x.v.s.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: B = None
        self.txt = txt

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

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

d = A("d")
k = B("k")
e = C("e")
l = C("l")
b = B("b")
a = A("a")
f = A("f")

d.q = k
d.x = b
k.w = b
k.v = l
e.q = l
e.s = b
l.q = e
l.s = k
b.w = k
b.v = e
a.q = b
a.x = k
f.q = b
f.x = b
assert d.x.v.s.w.w.w.w.txt == "b"