class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.r: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.u: F = None
        self.z: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: D = None
        self.s: B = None
        self.q: D = None
        self.z: B = None
        self.txt = txt

d = A("d")
k = B("k")
j = C("j")
i = D("i")
m = E("m")
a = F("a")

d.x = a
d.r = k
k.s = m
k.x = j
k.p = d
j.r = m
i.w = d
i.r = d
i.u = k
i.s = m
m.p = a
m.u = a
m.z = k
a.y = d
a.o = i
a.q = i
a.s = k
a.z = k
assert m.z.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.r: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.u: F = None
        self.z: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: D = None
        self.s: B = None
        self.q: D = None
        self.z: B = None
        self.txt = txt

d = A("d")
k = B("k")
j = C("j")
i = D("i")
m = E("m")
a = F("a")

d.x = a
d.r = k
k.s = m
k.x = j
k.p = d
j.r = m
i.w = d
i.r = d
i.u = k
i.s = m
m.p = a
m.u = a
m.z = k
a.y = d
a.o = i
a.q = i
a.s = k
a.z = k
assert m.z.p.r.txt == "k"