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

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

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

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

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

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

i = A("i")
a = B("a")
g = C("g")
b = D("b")
n = E("n")
m = F("m")

i.y = m
a.t = i
g.o = m
b.s = g
b.o = a
b.x = m
n.o = a
m.z = n
assert g.o.z.o.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

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

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

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

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

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

i = A("i")
a = B("a")
g = C("g")
b = D("b")
n = E("n")
m = F("m")

i.y = m
a.t = i
g.o = m
b.s = g
b.o = a
b.x = m
n.o = a
m.z = n
assert g.o.z.o.t.y.txt == "m"