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

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

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

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

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

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

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

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

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

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

k.p = g
k.t = g
k.q = a
c.p = b
c.t = m
c.z = h
g.s = m
g.w = c
b.o = h
m.s = g
m.w = c
h.p = g
h.t = g
h.q = b
f.p = g
f.q = b
f.t = m
i.p = b
i.t = m
i.z = k
a.o = f
assert f.p.s.w.z.t.s.txt == "m"