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

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

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

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

m = A("m")
g = B("g")
a = C("a")
c = D("c")
k = B("k")
l = A("l")
i = A("i")

m.q = l
m.o = k
m.s = c
m.y = g
g.w = k
g.s = k
g.p = k
a.t = g
a.u = k
a.s = i
a.q = c
c.s = m
c.u = m
k.w = g
k.s = g
k.p = g
l.q = i
l.o = g
l.s = c
l.y = k
i.q = l
i.o = g
i.s = c
i.y = k
assert c.s.o.w.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.o: B = None
        self.s: D = None
        self.y: B = None
        self.txt = txt

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

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

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

m = A("m")
g = B("g")
a = C("a")
c = D("c")
k = B("k")
l = A("l")
i = A("i")

m.q = l
m.o = k
m.s = c
m.y = g
g.w = k
g.s = k
g.p = k
a.t = g
a.u = k
a.s = i
a.q = c
c.s = m
c.u = m
k.w = g
k.s = g
k.p = g
l.q = i
l.o = g
l.s = c
l.y = k
i.q = l
i.o = g
i.s = c
i.y = k
assert c.s.o.w.p.p.txt == "g"