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

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

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

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

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

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

m = A("m")
n = B("n")
i = C("i")
g = D("g")
c = E("c")
e = F("e")

m.p = n
n.v = c
n.y = m
i.r = n
i.y = n
i.t = c
g.z = c
g.x = i
c.x = n
e.s = i
assert c.x.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

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

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

m = A("m")
n = B("n")
i = C("i")
g = D("g")
c = E("c")
e = F("e")

m.p = n
n.v = c
n.y = m
i.r = n
i.y = n
i.t = c
g.z = c
g.x = i
c.x = n
e.s = i
assert c.x.v.x.txt == "n"