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

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

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

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

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

d = A("d")
m = B("m")
e = C("e")
b = D("b")
g = E("g")
h = B("h")
k = E("k")

d.x = k
m.o = g
m.s = e
e.x = d
e.q = k
e.p = b
b.v = g
g.t = m
g.o = d
g.w = e
h.o = g
h.s = e
k.t = m
k.o = d
k.w = e
assert d.x.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

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

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

d = A("d")
m = B("m")
e = C("e")
b = D("b")
g = E("g")
h = B("h")
k = E("k")

d.x = k
m.o = g
m.s = e
e.x = d
e.q = k
e.p = b
b.v = g
g.t = m
g.o = d
g.w = e
h.o = g
h.s = e
k.t = m
k.o = d
k.w = e
assert d.x.t.s.txt == "e"