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

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: B = None
        self.z: D = None
        self.s: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

a.p = c
a.q = d
a.z = m
c.z = d
c.y = i
c.u = m
f.v = c
f.o = c
f.s = c
f.z = d
d.o = m
m.q = a
i.r = f
assert f.v.y.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: D = None
        self.z: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: B = None
        self.z: D = None
        self.s: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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