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

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

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

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

d = A("d")
g = B("g")
e = C("e")
l = D("l")
c = D("c")
a = D("a")

d.p = g
d.w = g
d.t = l
g.o = c
g.x = e
e.p = g
e.x = g
e.z = g
e.y = g
l.r = g
l.z = g
l.u = d
c.r = g
c.z = g
c.u = d
a.r = g
a.z = g
a.u = d
assert a.r.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: B = None
        self.t: D = None
        self.txt = txt

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

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

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

d = A("d")
g = B("g")
e = C("e")
l = D("l")
c = D("c")
a = D("a")

d.p = g
d.w = g
d.t = l
g.o = c
g.x = e
e.p = g
e.x = g
e.z = g
e.y = g
l.r = g
l.z = g
l.u = d
c.r = g
c.z = g
c.u = d
a.r = g
a.z = g
a.u = d
assert a.r.x.y.txt == "g"