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

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

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

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

f = A("f")
k = B("k")
d = C("d")
i = D("i")
g = C("g")
e = C("e")
j = A("j")

f.w = i
f.y = e
k.p = f
k.u = f
d.s = k
d.r = e
i.w = k
i.q = g
i.y = j
g.s = k
g.r = d
e.s = k
e.r = d
j.w = i
j.y = g
assert j.w.w.u.y.s.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: C = None
        self.txt = txt

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

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

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

f = A("f")
k = B("k")
d = C("d")
i = D("i")
g = C("g")
e = C("e")
j = A("j")

f.w = i
f.y = e
k.p = f
k.u = f
d.s = k
d.r = e
i.w = k
i.q = g
i.y = j
g.s = k
g.r = d
e.s = k
e.r = d
j.w = i
j.y = g
assert j.w.w.u.y.s.p.y.txt == "e"