class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: D = None
        self.o: D = None
        self.txt = txt

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

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

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

i = A("i")
f = B("f")
b = C("b")
e = D("e")
g = B("g")

i.u = g
i.r = e
i.o = e
f.s = b
f.p = e
f.w = e
b.p = f
e.t = b
g.s = b
g.p = e
g.w = e
assert b.p.s.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: D = None
        self.o: D = None
        self.txt = txt

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

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

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

i = A("i")
f = B("f")
b = C("b")
e = D("e")
g = B("g")

i.u = g
i.r = e
i.o = e
f.s = b
f.p = e
f.w = e
b.p = f
e.t = b
g.s = b
g.p = e
g.w = e
assert b.p.s.p.p.txt == "e"