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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.q: G = None
        self.z: B = None
        self.u: A = None
        self.txt = txt

m = A("m")
g = B("g")
d = C("d")
j = D("j")
f = E("f")
k = F("k")
b = G("b")
h = G("h")

m.t = g
g.z = m
g.x = j
g.r = j
d.w = g
j.t = b
j.o = g
f.o = d
f.t = j
f.q = m
f.z = b
f.v = k
f.u = k
f.s = h
k.v = d
b.q = h
b.z = g
b.u = m
h.q = b
h.z = g
h.u = m
assert f.o.w.x.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.q: G = None
        self.z: B = None
        self.u: A = None
        self.txt = txt

m = A("m")
g = B("g")
d = C("d")
j = D("j")
f = E("f")
k = F("k")
b = G("b")
h = G("h")

m.t = g
g.z = m
g.x = j
g.r = j
d.w = g
j.t = b
j.o = g
f.o = d
f.t = j
f.q = m
f.z = b
f.v = k
f.u = k
f.s = h
k.v = d
b.q = h
b.z = g
b.u = m
h.q = b
h.z = g
h.u = m
assert f.o.w.x.t.u.t.txt == "g"