class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: B = 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.s: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: D = None
        self.t: D = None
        self.x: D = None
        self.txt = txt

b = A("b")
l = B("l")
i = C("i")
h = D("h")
g = D("g")

b.w = h
b.p = l
l.q = i
i.s = l
h.p = g
h.t = g
h.x = g
g.p = h
g.t = h
g.x = h
assert i.s.q.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: B = 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.s: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: D = None
        self.t: D = None
        self.x: D = None
        self.txt = txt

b = A("b")
l = B("l")
i = C("i")
h = D("h")
g = D("g")

b.w = h
b.p = l
l.q = i
i.s = l
h.p = g
h.t = g
h.x = g
g.p = h
g.t = h
g.x = h
assert i.s.q.s.q.s.txt == "l"