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

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

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

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

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

d.w = i
d.o = c
h.y = k
h.q = d
a.u = k
a.r = k
a.z = h
k.y = a
k.s = a
k.p = a
j.y = k
j.q = c
f.w = c
f.o = c
c.w = d
c.o = i
i.w = f
i.o = c
assert f.o.w.o.w.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: A = None
        self.txt = txt

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

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

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

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

d.w = i
d.o = c
h.y = k
h.q = d
a.u = k
a.r = k
a.z = h
k.y = a
k.s = a
k.p = a
j.y = k
j.q = c
f.w = c
f.o = c
c.w = d
c.o = i
i.w = f
i.o = c
assert f.o.w.o.w.w.o.w.txt == "d"