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

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

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

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

d = A("d")
f = B("f")
e = C("e")
b = D("b")

d.w = f
d.u = b
d.p = b
f.y = e
e.x = d
e.p = b
b.y = e
assert f.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: D = None
        self.p: D = None
        self.txt = txt

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

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

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

d = A("d")
f = B("f")
e = C("e")
b = D("b")

d.w = f
d.u = b
d.p = b
f.y = e
e.x = d
e.p = b
b.y = e
assert f.y.p.y.txt == "e"