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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: C = None
        self.w: A = None
        self.q: C = None
        self.txt = txt

a = A("a")
k = B("k")
j = C("j")
b = D("b")
n = E("n")
f = F("f")

a.w = b
a.r = k
a.x = j
k.p = a
k.w = n
j.p = k
j.u = a
b.z = f
b.s = f
b.u = j
b.w = k
b.r = a
n.q = f
n.x = b
f.z = a
f.w = a
f.u = j
f.q = j
assert f.z.r.p.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.r: B = None
        self.x: C = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: C = None
        self.w: A = None
        self.q: C = None
        self.txt = txt

a = A("a")
k = B("k")
j = C("j")
b = D("b")
n = E("n")
f = F("f")

a.w = b
a.r = k
a.x = j
k.p = a
k.w = n
j.p = k
j.u = a
b.z = f
b.s = f
b.u = j
b.w = k
b.r = a
n.q = f
n.x = b
f.z = a
f.w = a
f.u = j
f.q = j
assert f.z.r.p.r.w.txt == "n"