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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.u: A = None
        self.txt = txt

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

g = A("g")
n = B("n")
m = C("m")
h = D("h")
a = E("a")
d = F("d")

g.z = m
g.s = a
n.y = a
m.z = d
h.t = n
h.w = d
a.x = d
a.u = g
d.u = m
d.t = m
d.q = a
d.p = h
d.s = h
assert g.z.z.t.z.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.s: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.u: A = None
        self.txt = txt

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

g = A("g")
n = B("n")
m = C("m")
h = D("h")
a = E("a")
d = F("d")

g.z = m
g.s = a
n.y = a
m.z = d
h.t = n
h.w = d
a.x = d
a.u = g
d.u = m
d.t = m
d.q = a
d.p = h
d.s = h
assert g.z.z.t.z.s.w.txt == "d"