class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: F = None
        self.r: B = None
        self.w: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: A = None
        self.v: F = None
        self.q: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: A = None
        self.x: A = None
        self.q: C = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
n = C("n")
c = D("c")
i = E("i")
m = F("m")
d = D("d")

a.p = n
a.y = m
a.r = f
a.w = f
f.o = i
f.q = i
f.u = a
f.z = d
f.r = c
n.r = a
n.z = a
n.v = m
n.q = d
c.y = f
c.v = a
c.x = a
c.q = n
i.z = f
m.y = a
m.v = f
m.p = i
d.y = f
d.v = a
d.x = a
d.q = n
assert m.y.y.p.z.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: F = None
        self.r: B = None
        self.w: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: A = None
        self.v: F = None
        self.q: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: A = None
        self.x: A = None
        self.q: C = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
n = C("n")
c = D("c")
i = E("i")
m = F("m")
d = D("d")

a.p = n
a.y = m
a.r = f
a.w = f
f.o = i
f.q = i
f.u = a
f.z = d
f.r = c
n.r = a
n.z = a
n.v = m
n.q = d
c.y = f
c.v = a
c.x = a
c.q = n
i.z = f
m.y = a
m.v = f
m.p = i
d.y = f
d.v = a
d.x = a
d.q = n
assert m.y.y.p.z.z.y.txt == "f"