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

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: C = None
        self.w: B = None
        self.t: C = None
        self.p: A = None
        self.o: E = None
        self.q: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: G = None
        self.txt = txt

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

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

h = A("h")
b = B("b")
i = C("i")
a = D("a")
n = E("n")
j = F("j")
l = G("l")
m = G("m")
f = B("f")

h.x = n
b.z = a
i.t = a
a.r = h
a.p = h
a.q = h
a.z = i
a.t = i
a.w = b
a.o = n
n.o = m
j.w = n
j.y = n
j.s = i
l.z = a
l.x = m
l.q = b
m.z = a
m.x = l
m.q = b
f.z = a
assert j.y.o.z.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: C = None
        self.w: B = None
        self.t: C = None
        self.p: A = None
        self.o: E = None
        self.q: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: G = None
        self.txt = txt

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

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

h = A("h")
b = B("b")
i = C("i")
a = D("a")
n = E("n")
j = F("j")
l = G("l")
m = G("m")
f = B("f")

h.x = n
b.z = a
i.t = a
a.r = h
a.p = h
a.q = h
a.z = i
a.t = i
a.w = b
a.o = n
n.o = m
j.w = n
j.y = n
j.s = i
l.z = a
l.x = m
l.q = b
m.z = a
m.x = l
m.q = b
f.z = a
assert j.y.o.z.q.x.txt == "n"