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

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

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

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

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

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

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

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

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

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

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

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

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

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

d.p = m
d.y = i
d.q = c
m.z = c
m.r = i
m.s = i
m.u = f
m.o = f
m.p = f
f.r = m
f.z = c
i.p = m
j.x = i
j.t = c
c.q = i
assert m.z.q.p.o.r.txt == "m"