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

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.z: B = None
        self.y: B = None
        self.v: E = None
        self.x: A = None
        self.txt = txt

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

d = A("d")
f = B("f")
l = C("l")
m = D("m")
a = E("a")
b = C("b")
g = E("g")
i = D("i")

d.v = g
f.v = g
l.p = d
m.s = b
m.z = f
m.y = f
m.v = g
m.x = d
a.r = m
a.w = i
a.q = g
a.u = d
b.p = d
g.r = i
g.w = m
g.q = a
g.u = d
i.s = l
i.z = f
i.y = f
i.v = a
i.x = d
assert d.v.w.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.z: B = None
        self.y: B = None
        self.v: E = None
        self.x: A = None
        self.txt = txt

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

d = A("d")
f = B("f")
l = C("l")
m = D("m")
a = E("a")
b = C("b")
g = E("g")
i = D("i")

d.v = g
f.v = g
l.p = d
m.s = b
m.z = f
m.y = f
m.v = g
m.x = d
a.r = m
a.w = i
a.q = g
a.u = d
b.p = d
g.r = i
g.w = m
g.q = a
g.u = d
i.s = l
i.z = f
i.y = f
i.v = a
i.x = d
assert d.v.w.x.v.txt == "g"