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

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

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

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

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

d.z = k
n.s = a
n.o = e
n.q = k
e.p = k
e.y = m
m.x = f
m.s = n
k.z = f
f.z = k
h.x = d
h.s = a
a.s = n
a.o = e
a.q = k
g.x = f
g.s = a
assert m.s.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

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

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

d.z = k
n.s = a
n.o = e
n.q = k
e.p = k
e.y = m
m.x = f
m.s = n
k.z = f
f.z = k
h.x = d
h.s = a
a.s = n
a.o = e
a.q = k
g.x = f
g.s = a
assert m.s.o.y.txt == "m"