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

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

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

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

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

h.r = m
h.o = g
h.x = j
i.p = h
m.s = e
d.z = a
d.x = g
a.p = h
g.z = i
g.x = d
j.r = n
j.o = d
j.x = h
e.r = n
e.o = g
e.x = h
f.p = j
n.s = j
assert e.r.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: D = None
        self.x: A = None
        self.txt = txt

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

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

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

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

h.r = m
h.o = g
h.x = j
i.p = h
m.s = e
d.z = a
d.x = g
a.p = h
g.z = i
g.x = d
j.r = n
j.o = d
j.x = h
e.r = n
e.o = g
e.x = h
f.p = j
n.s = j
assert e.r.s.x.txt == "h"