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

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

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

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

c = A("c")
k = B("k")
e = C("e")
n = D("n")
g = C("g")
f = D("f")
h = D("h")
i = B("i")

c.w = h
k.w = c
e.w = g
e.r = i
n.t = k
n.o = k
n.w = c
g.w = e
g.r = k
f.t = i
f.o = i
f.w = c
h.t = i
h.w = c
h.o = k
i.w = c
assert i.w.w.o.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
e = C("e")
n = D("n")
g = C("g")
f = D("f")
h = D("h")
i = B("i")

c.w = h
k.w = c
e.w = g
e.r = i
n.t = k
n.o = k
n.w = c
g.w = e
g.r = k
f.t = i
f.o = i
f.w = c
h.t = i
h.w = c
h.o = k
i.w = c
assert i.w.w.o.w.w.txt == "h"