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

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

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

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

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

g = A("g")
d = B("d")
c = C("c")
h = D("h")
l = E("l")
k = A("k")

g.s = l
g.u = k
d.z = l
d.x = l
d.s = g
d.w = k
c.z = k
h.p = c
h.s = c
h.u = c
h.y = l
l.p = g
l.v = g
l.s = h
l.u = d
l.q = c
k.s = l
k.u = g
assert h.p.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.u: A = None
        self.txt = txt

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

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

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

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

g = A("g")
d = B("d")
c = C("c")
h = D("h")
l = E("l")
k = A("k")

g.s = l
g.u = k
d.z = l
d.x = l
d.s = g
d.w = k
c.z = k
h.p = c
h.s = c
h.u = c
h.y = l
l.p = g
l.v = g
l.s = h
l.u = d
l.q = c
k.s = l
k.u = g
assert h.p.z.u.txt == "g"