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

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.r: F = None
        self.w: G = None
        self.s: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.w: G = None
        self.z: C = None
        self.x: E = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.r: F = None
        self.z: F = None
        self.t: A = None
        self.p: F = None
        self.u: C = None
        self.txt = txt

f = A("f")
d = B("d")
g = C("g")
n = D("n")
i = E("i")
e = F("e")
m = G("m")

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

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.r: F = None
        self.w: G = None
        self.s: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.w: G = None
        self.z: C = None
        self.x: E = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.r: F = None
        self.z: F = None
        self.t: A = None
        self.p: F = None
        self.u: C = None
        self.txt = txt

f = A("f")
d = B("d")
g = C("g")
n = D("n")
i = E("i")
e = F("e")
m = G("m")

f.t = d
f.p = n
d.t = i
d.s = i
d.r = e
d.w = m
g.q = i
g.v = n
g.o = m
n.w = m
n.z = g
n.x = i
i.y = f
i.p = f
i.q = d
i.u = d
i.x = d
i.t = n
i.r = g
e.p = n
e.v = d
m.r = e
m.z = e
m.p = e
m.t = f
m.u = g
assert d.s.q.w.t.txt == "f"