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

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

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

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

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

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

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

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

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

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

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