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

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

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

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

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

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

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

d.p = e
d.x = e
d.z = n
i.x = d
e.o = d
h.z = n
n.q = e
n.v = i
g.p = h
g.z = n
g.u = i
g.v = i
assert i.x.z.v.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: E = None
        self.x: C = None
        self.txt = txt

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

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

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

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

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

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

d.p = e
d.x = e
d.z = n
i.x = d
e.o = d
h.z = n
n.q = e
n.v = i
g.p = h
g.z = n
g.u = i
g.v = i
assert i.x.z.v.x.z.txt == "n"