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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: D = None
        self.txt = txt

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

b.p = l
b.q = f
d.w = i
d.o = i
f.q = d
f.z = n
i.x = b
i.r = b
i.q = b
i.y = d
i.w = f
i.t = l
l.v = d
e.q = b
n.x = b
n.s = i
assert d.w.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.q: C = None
        self.txt = txt

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: D = None
        self.txt = txt

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

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