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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: A = None
        self.r: D = None
        self.o: D = None
        self.p: C = None
        self.x: A = None
        self.txt = txt

i = A("i")
a = B("a")
c = C("c")
h = D("h")
g = E("g")
n = F("n")
f = C("f")

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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: A = None
        self.r: D = None
        self.o: D = None
        self.p: C = None
        self.x: A = None
        self.txt = txt

i = A("i")
a = B("a")
c = C("c")
h = D("h")
g = E("g")
n = F("n")
f = C("f")

i.z = a
a.r = n
a.o = n
c.x = n
h.y = a
g.s = c
n.t = c
n.p = c
n.s = i
n.x = i
n.r = h
n.o = h
f.x = n
assert g.s.x.s.z.r.txt == "n"