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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
n = C("n")
m = D("m")
l = E("l")
k = E("k")

g.v = n
g.q = n
g.w = m
a.o = m
n.x = a
n.q = a
n.y = g
m.t = l
m.u = a
l.s = n
l.q = g
l.u = g
k.s = n
k.q = g
k.u = g
assert a.o.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.q: C = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
n = C("n")
m = D("m")
l = E("l")
k = E("k")

g.v = n
g.q = n
g.w = m
a.o = m
n.x = a
n.q = a
n.y = g
m.t = l
m.u = a
l.s = n
l.q = g
l.u = g
k.s = n
k.q = g
k.u = g
assert a.o.u.o.u.txt == "a"