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

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

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

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

a = A("a")
g = B("g")
f = C("f")
i = D("i")
j = D("j")
h = C("h")
m = C("m")
k = A("k")
d = C("d")
b = C("b")

a.y = k
g.t = d
g.o = i
g.x = m
f.w = a
f.r = h
f.y = k
i.q = a
i.t = f
i.w = g
j.q = a
j.t = f
j.w = g
h.w = a
h.y = a
h.r = b
m.w = k
m.r = b
m.y = a
k.y = a
d.w = k
d.y = k
d.r = m
b.w = a
b.y = a
b.r = d
assert d.r.w.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

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

a = A("a")
g = B("g")
f = C("f")
i = D("i")
j = D("j")
h = C("h")
m = C("m")
k = A("k")
d = C("d")
b = C("b")

a.y = k
g.t = d
g.o = i
g.x = m
f.w = a
f.r = h
f.y = k
i.q = a
i.t = f
i.w = g
j.q = a
j.t = f
j.w = g
h.w = a
h.y = a
h.r = b
m.w = k
m.r = b
m.y = a
k.y = a
d.w = k
d.y = k
d.r = m
b.w = a
b.y = a
b.r = d
assert d.r.w.y.y.y.y.y.y.txt == "k"