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

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

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

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

h = A("h")
n = B("n")
d = C("d")
b = D("b")
a = B("a")
e = C("e")
l = A("l")
k = C("k")
j = C("j")
c = A("c")

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

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

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

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

h = A("h")
n = B("n")
d = C("d")
b = D("b")
a = B("a")
e = C("e")
l = A("l")
k = C("k")
j = C("j")
c = A("c")

h.o = c
h.p = c
h.y = b
h.s = b
n.r = h
d.w = b
b.o = j
a.r = l
e.w = b
l.o = c
l.y = b
l.s = b
l.p = h
k.w = b
j.w = b
c.o = l
c.y = b
c.s = b
c.p = h
assert b.o.w.o.w.o.w.o.txt == "j"