class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: D = None
        self.o: B = None
        self.t: C = 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.q: D = None
        self.u: A = None
        self.txt = txt

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

h = A("h")
l = B("l")
g = C("g")
e = D("e")

h.w = g
h.t = g
h.x = e
h.o = l
l.y = g
g.q = e
g.u = h
e.x = l
e.r = l
e.p = g
assert h.x.p.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: D = None
        self.o: B = None
        self.t: C = 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.q: D = None
        self.u: A = None
        self.txt = txt

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

h = A("h")
l = B("l")
g = C("g")
e = D("e")

h.w = g
h.t = g
h.x = e
h.o = l
l.y = g
g.q = e
g.u = h
e.x = l
e.r = l
e.p = g
assert h.x.p.u.x.txt == "e"