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

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

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

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

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

m = A("m")
g = B("g")
h = C("h")
a = D("a")
l = E("l")
i = D("i")

m.q = i
m.w = g
m.v = h
g.w = m
g.q = m
g.y = h
g.s = i
h.w = a
h.t = a
h.u = g
a.o = l
a.r = l
a.p = m
l.o = g
l.v = g
l.y = g
l.s = h
l.w = m
i.o = l
i.r = l
i.p = m
assert i.p.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.w: B = None
        self.v: C = None
        self.txt = txt

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

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

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

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

m = A("m")
g = B("g")
h = C("h")
a = D("a")
l = E("l")
i = D("i")

m.q = i
m.w = g
m.v = h
g.w = m
g.q = m
g.y = h
g.s = i
h.w = a
h.t = a
h.u = g
a.o = l
a.r = l
a.p = m
l.o = g
l.v = g
l.y = g
l.s = h
l.w = m
i.o = l
i.r = l
i.p = m
assert i.p.q.r.txt == "l"