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

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

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

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

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

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

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

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

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

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

j.p = c
j.z = k
j.q = g
j.w = h
g.s = h
k.s = g
k.v = g
k.o = g
k.x = h
h.x = g
n.p = j
n.z = k
n.q = g
n.w = h
c.p = m
c.z = k
c.q = g
c.w = h
m.p = n
m.z = k
m.q = g
m.w = h
assert m.p.w.x.s.x.s.txt == "h"