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

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.p: C = None
        self.r: D = None
        self.o: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.y: A = None
        self.w: F = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.p: C = None
        self.r: D = None
        self.o: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.y: A = None
        self.w: F = None
        self.txt = txt

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

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

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

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

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