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

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

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

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

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

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

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

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

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

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

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

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

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