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

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

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

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

g = A("g")
m = B("m")
e = C("e")
d = D("d")
i = E("i")
c = F("c")
f = A("f")
h = E("h")

g.s = f
g.t = m
g.z = e
m.s = d
e.w = m
e.s = d
d.s = f
i.y = d
i.v = g
c.p = g
c.t = g
f.s = g
f.t = m
f.z = e
h.y = d
h.v = f
assert g.t.s.s.t.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: B = None
        self.z: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

g = A("g")
m = B("m")
e = C("e")
d = D("d")
i = E("i")
c = F("c")
f = A("f")
h = E("h")

g.s = f
g.t = m
g.z = e
m.s = d
e.w = m
e.s = d
d.s = f
i.y = d
i.v = g
c.p = g
c.t = g
f.s = g
f.t = m
f.z = e
h.y = d
h.v = f
assert g.t.s.s.t.s.s.txt == "f"