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

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

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

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

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

a = A("a")
d = B("d")
f = C("f")
b = D("b")
m = E("m")
n = B("n")
k = C("k")

a.x = b
d.x = m
d.v = m
d.s = a
d.w = f
d.p = f
f.t = n
f.s = m
f.r = m
b.o = m
b.q = n
m.t = n
n.x = m
n.v = m
n.s = a
n.w = k
n.p = k
k.t = d
k.s = m
k.r = m
assert k.r.t.x.t.x.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

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

a = A("a")
d = B("d")
f = C("f")
b = D("b")
m = E("m")
n = B("n")
k = C("k")

a.x = b
d.x = m
d.v = m
d.s = a
d.w = f
d.p = f
f.t = n
f.s = m
f.r = m
b.o = m
b.q = n
m.t = n
n.x = m
n.v = m
n.s = a
n.w = k
n.p = k
k.t = d
k.s = m
k.r = m
assert k.r.t.x.t.x.t.s.txt == "a"