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

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

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

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

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

d.w = g
d.y = j
d.z = e
g.u = c
g.y = j
m.p = c
m.s = j
j.o = c
j.r = m
f.p = k
f.s = j
k.u = n
k.y = j
e.w = c
e.y = j
e.z = d
c.u = i
c.y = j
n.u = i
n.y = j
i.u = c
i.y = j
assert g.u.u.u.u.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: D = None
        self.z: A = None
        self.txt = txt

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

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

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

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

d.w = g
d.y = j
d.z = e
g.u = c
g.y = j
m.p = c
m.s = j
j.o = c
j.r = m
f.p = k
f.s = j
k.u = n
k.y = j
e.w = c
e.y = j
e.z = d
c.u = i
c.y = j
n.u = i
n.y = j
i.u = c
i.y = j
assert g.u.u.u.u.y.r.txt == "m"