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

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.q: F = None
        self.p: A = None
        self.s: D = None
        self.t: D = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.u: D = None
        self.t: A = None
        self.s: D = None
        self.q: A = None
        self.r: E = None
        self.v: D = None
        self.txt = txt

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

h.r = m
h.z = g
g.q = m
g.r = i
e.w = d
e.q = m
e.p = h
e.s = i
e.t = i
i.p = g
i.t = d
i.s = d
i.z = e
d.w = g
m.u = i
m.s = i
m.v = i
m.t = h
m.q = h
m.r = d
assert h.z.r.p.q.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.z: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.q: F = None
        self.p: A = None
        self.s: D = None
        self.t: D = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.u: D = None
        self.t: A = None
        self.s: D = None
        self.q: A = None
        self.r: E = None
        self.v: D = None
        self.txt = txt

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

h.r = m
h.z = g
g.q = m
g.r = i
e.w = d
e.q = m
e.p = h
e.s = i
e.t = i
i.p = g
i.t = d
i.s = d
i.z = e
d.w = g
m.u = i
m.s = i
m.v = i
m.t = h
m.q = h
m.r = d
assert h.z.r.p.q.t.z.txt == "g"