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

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.u: D = None
        self.q: C = None
        self.z: C = None
        self.r: D = None
        self.txt = txt

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

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

g = A("g")
n = B("n")
j = C("j")
i = D("i")
m = E("m")
h = C("h")
e = B("e")

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

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.u: D = None
        self.q: C = None
        self.z: C = None
        self.r: D = None
        self.txt = txt

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

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

g = A("g")
n = B("n")
j = C("j")
i = D("i")
m = E("m")
h = C("h")
e = B("e")

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