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

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

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

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

e = A("e")
b = B("b")
m = C("m")
d = D("d")
l = C("l")
g = B("g")
h = C("h")
n = D("n")

e.p = n
e.x = n
e.y = m
b.w = d
b.u = l
b.y = e
m.z = d
m.t = d
d.x = e
d.p = e
l.z = d
l.t = d
g.w = d
g.u = m
g.y = e
h.z = d
h.t = n
n.x = e
n.p = e
assert h.z.x.y.t.x.y.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.y: C = None
        self.x: D = None
        self.txt = txt

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

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

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

e = A("e")
b = B("b")
m = C("m")
d = D("d")
l = C("l")
g = B("g")
h = C("h")
n = D("n")

e.p = n
e.x = n
e.y = m
b.w = d
b.u = l
b.y = e
m.z = d
m.t = d
d.x = e
d.p = e
l.z = d
l.t = d
g.w = d
g.u = m
g.y = e
h.z = d
h.t = n
n.x = e
n.p = e
assert h.z.x.y.t.x.y.z.x.txt == "e"