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

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

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

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

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

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

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

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

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

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

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