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

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

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

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

g = A("g")
a = B("a")
j = C("j")
e = D("e")
k = B("k")
n = A("n")

g.q = n
g.p = n
g.r = n
g.o = a
a.q = e
j.r = a
j.w = n
j.y = e
j.s = g
e.w = j
e.s = j
e.q = j
k.q = e
n.q = g
n.p = g
n.r = g
n.o = k
assert k.q.w.w.r.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.p: A = None
        self.r: A = None
        self.o: B = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
j = C("j")
e = D("e")
k = B("k")
n = A("n")

g.q = n
g.p = n
g.r = n
g.o = a
a.q = e
j.r = a
j.w = n
j.y = e
j.s = g
e.w = j
e.s = j
e.q = j
k.q = e
n.q = g
n.p = g
n.r = g
n.o = k
assert k.q.w.w.r.q.o.txt == "k"