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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: A = None
        self.u: D = None
        self.q: B = None
        self.txt = txt

m = A("m")
n = B("n")
h = C("h")
d = D("d")
g = E("g")
b = F("b")
i = G("i")
l = C("l")
e = D("e")
j = C("j")

m.u = e
n.w = i
n.x = e
h.u = d
h.y = j
d.y = b
d.w = e
d.r = m
g.z = n
b.y = e
b.w = e
i.z = g
i.p = m
i.u = e
i.q = n
l.u = d
l.y = h
e.y = b
e.w = d
e.r = m
j.u = d
j.y = l
assert d.y.y.r.u.w.y.w.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: A = None
        self.u: D = None
        self.q: B = None
        self.txt = txt

m = A("m")
n = B("n")
h = C("h")
d = D("d")
g = E("g")
b = F("b")
i = G("i")
l = C("l")
e = D("e")
j = C("j")

m.u = e
n.w = i
n.x = e
h.u = d
h.y = j
d.y = b
d.w = e
d.r = m
g.z = n
b.y = e
b.w = e
i.z = g
i.p = m
i.u = e
i.q = n
l.u = d
l.y = h
e.y = b
e.w = d
e.r = m
j.u = d
j.y = l
assert d.y.y.r.u.w.y.w.y.w.txt == "e"