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

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

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

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

a = A("a")
j = B("j")
i = C("i")
c = D("c")
d = D("d")
m = C("m")
g = D("g")
n = A("n")
h = B("h")

a.u = n
a.s = h
j.p = c
j.y = i
i.o = g
i.z = n
i.r = m
i.q = m
c.s = m
c.x = g
d.s = m
d.x = g
m.o = d
m.z = n
m.r = i
m.q = i
g.s = i
g.x = c
n.u = a
n.s = h
h.p = g
h.y = m
assert d.x.s.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: B = None
        self.txt = txt

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

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

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

a = A("a")
j = B("j")
i = C("i")
c = D("c")
d = D("d")
m = C("m")
g = D("g")
n = A("n")
h = B("h")

a.u = n
a.s = h
j.p = c
j.y = i
i.o = g
i.z = n
i.r = m
i.q = m
c.s = m
c.x = g
d.s = m
d.x = g
m.o = d
m.z = n
m.r = i
m.q = i
g.s = i
g.x = c
n.u = a
n.s = h
h.p = g
h.y = m
assert d.x.s.o.s.txt == "i"