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

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

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

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

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

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

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

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

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

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

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