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

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

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

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

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

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

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

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

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

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

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

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

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

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

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