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

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

class C:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: A = None
        self.txt = txt

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

d = A("d")
h = B("h")
m = C("m")
n = D("n")
k = C("k")
a = B("a")
j = D("j")
c = C("c")
i = D("i")

d.o = j
d.y = h
h.w = c
m.t = k
m.s = d
n.w = h
k.t = c
k.s = d
a.w = k
j.w = a
c.t = m
c.s = d
i.w = h
assert c.t.t.t.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.y: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: A = None
        self.txt = txt

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

d = A("d")
h = B("h")
m = C("m")
n = D("n")
k = C("k")
a = B("a")
j = D("j")
c = C("c")
i = D("i")

d.o = j
d.y = h
h.w = c
m.t = k
m.s = d
n.w = h
k.t = c
k.s = d
a.w = k
j.w = a
c.t = m
c.s = d
i.w = h
assert c.t.t.t.s.o.txt == "j"