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

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

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

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

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

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

g = A("g")
n = B("n")
b = C("b")
i = D("i")
l = E("l")
h = F("h")

g.z = n
g.x = i
g.p = i
n.p = g
n.s = l
n.z = b
b.z = g
b.y = g
b.x = g
b.r = g
b.w = i
i.p = b
i.w = b
i.s = n
l.w = i
l.v = b
h.s = g
assert g.z.p.x.s.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: D = None
        self.p: D = None
        self.txt = txt

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

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

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

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

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

g = A("g")
n = B("n")
b = C("b")
i = D("i")
l = E("l")
h = F("h")

g.z = n
g.x = i
g.p = i
n.p = g
n.s = l
n.z = b
b.z = g
b.y = g
b.x = g
b.r = g
b.w = i
i.p = b
i.w = b
i.s = n
l.w = i
l.v = b
h.s = g
assert g.z.p.x.s.s.w.txt == "i"