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

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

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

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

d = A("d")
j = B("j")
m = C("m")
n = D("n")
k = A("k")
h = D("h")
g = C("g")
c = A("c")
f = B("f")

d.s = j
d.y = f
d.z = g
j.u = f
j.o = f
j.p = k
j.z = n
m.p = g
n.q = k
n.z = m
n.w = c
n.u = g
k.s = f
k.y = f
k.z = g
h.q = k
h.w = k
h.z = g
h.u = m
g.p = m
c.s = f
c.y = j
c.z = g
f.u = j
f.o = j
f.p = c
f.z = n
assert d.z.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: B = None
        self.z: C = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
m = C("m")
n = D("n")
k = A("k")
h = D("h")
g = C("g")
c = A("c")
f = B("f")

d.s = j
d.y = f
d.z = g
j.u = f
j.o = f
j.p = k
j.z = n
m.p = g
n.q = k
n.z = m
n.w = c
n.u = g
k.s = f
k.y = f
k.z = g
h.q = k
h.w = k
h.z = g
h.u = m
g.p = m
c.s = f
c.y = j
c.z = g
f.u = j
f.o = j
f.p = c
f.z = n
assert d.z.p.p.txt == "g"