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

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: C = None
        self.txt = txt

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

e = A("e")
a = B("a")
d = C("d")
g = D("g")
m = C("m")
i = B("i")

e.u = g
a.x = i
a.y = i
a.w = i
d.v = e
d.q = m
g.p = e
g.t = e
m.v = e
m.q = d
i.x = a
i.y = a
i.w = a
assert m.q.v.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: C = None
        self.txt = txt

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

e = A("e")
a = B("a")
d = C("d")
g = D("g")
m = C("m")
i = B("i")

e.u = g
a.x = i
a.y = i
a.w = i
d.v = e
d.q = m
g.p = e
g.t = e
m.v = e
m.q = d
i.x = a
i.y = a
i.w = a
assert m.q.v.u.p.txt == "e"