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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: E = None
        self.v: C = None
        self.w: E = None
        self.u: D = None
        self.txt = txt

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

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

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

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

l.x = e
e.x = a
e.u = a
e.r = g
e.w = g
e.v = h
h.q = l
a.v = g
a.y = l
a.x = e
g.w = a
g.t = a
g.u = h
g.z = h
g.y = h
assert a.v.w.x.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: E = None
        self.v: C = None
        self.w: E = None
        self.u: D = None
        self.txt = txt

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

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

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

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

l.x = e
e.x = a
e.u = a
e.r = g
e.w = g
e.v = h
h.q = l
a.v = g
a.y = l
a.x = e
g.w = a
g.t = a
g.u = h
g.z = h
g.y = h
assert a.v.w.x.v.q.txt == "l"