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

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

class C:
    def __init__(self, txt: str):
        self.u: E = None
        self.v: B = None
        self.p: F = None
        self.txt = txt

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

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.u: E = None
        self.v: B = None
        self.p: F = None
        self.txt = txt

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

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

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

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

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