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

class B:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: D = None
        self.z: D = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
i = C("i")
l = D("l")
h = E("h")
d = A("d")
f = B("f")
m = D("m")

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

class B:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: D = None
        self.z: D = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
i = C("i")
l = D("l")
h = E("h")
d = A("d")
f = B("f")
m = D("m")

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