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

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: A = None
        self.s: D = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: A = None
        self.s: D = None
        self.txt = txt

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

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

d.u = a
d.z = j
g.x = e
g.s = d
g.u = c
c.r = j
c.o = d
c.s = h
h.p = k
h.w = d
h.s = a
k.x = g
k.s = d
k.u = j
e.x = g
e.s = d
e.u = j
j.r = c
j.o = d
j.s = a
a.p = e
a.w = d
a.s = h
assert e.s.z.s.txt == "a"