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

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

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

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

d = A("d")
h = B("h")
e = C("e")
b = D("b")
k = D("k")
c = B("c")
j = C("j")
g = D("g")

d.y = e
d.s = e
d.p = c
h.o = g
h.w = d
e.x = c
e.r = k
e.t = j
e.p = d
b.p = d
b.t = d
b.y = c
b.z = e
k.p = d
k.t = d
k.y = c
k.z = j
c.o = g
c.w = d
j.x = h
j.r = b
j.t = e
j.p = d
g.p = d
g.t = d
g.y = h
g.z = e
assert e.x.o.y.o.p.p.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: B = None
        self.s: C = None
        self.txt = txt

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

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

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

d = A("d")
h = B("h")
e = C("e")
b = D("b")
k = D("k")
c = B("c")
j = C("j")
g = D("g")

d.y = e
d.s = e
d.p = c
h.o = g
h.w = d
e.x = c
e.r = k
e.t = j
e.p = d
b.p = d
b.t = d
b.y = c
b.z = e
k.p = d
k.t = d
k.y = c
k.z = j
c.o = g
c.w = d
j.x = h
j.r = b
j.t = e
j.p = d
g.p = d
g.t = d
g.y = h
g.z = e
assert e.x.o.y.o.p.p.o.z.txt == "e"