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

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

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

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

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

h.o = m
h.r = m
h.q = k
h.p = e
a.u = j
a.p = k
j.w = e
j.r = n
j.s = h
k.p = n
m.o = h
m.q = k
m.r = f
m.p = j
n.p = k
g.u = j
g.p = n
e.w = j
e.r = n
e.s = m
f.o = m
f.q = n
f.r = h
f.p = e
c.u = j
c.p = n
assert c.u.w.w.w.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: D = None
        self.r: A = None
        self.p: C = None
        self.txt = txt

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

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

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

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

h.o = m
h.r = m
h.q = k
h.p = e
a.u = j
a.p = k
j.w = e
j.r = n
j.s = h
k.p = n
m.o = h
m.q = k
m.r = f
m.p = j
n.p = k
g.u = j
g.p = n
e.w = j
e.r = n
e.s = m
f.o = m
f.q = n
f.r = h
f.p = e
c.u = j
c.p = n
assert c.u.w.w.w.s.q.txt == "k"