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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: D = None
        self.x: A = None
        self.z: B = None
        self.s: C = None
        self.r: D = None
        self.txt = txt

m = A("m")
k = B("k")
f = C("f")
g = D("g")
h = E("h")
i = F("i")
n = G("n")

m.x = g
m.u = h
k.z = f
k.p = f
k.q = i
k.r = m
f.s = m
g.x = f
g.q = n
h.z = i
h.x = m
h.v = g
i.t = n
i.w = n
n.y = m
n.x = m
n.o = g
n.r = g
n.z = k
n.s = f
assert g.q.z.r.u.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: E = None
        self.txt = txt

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: D = None
        self.x: A = None
        self.z: B = None
        self.s: C = None
        self.r: D = None
        self.txt = txt

m = A("m")
k = B("k")
f = C("f")
g = D("g")
h = E("h")
i = F("i")
n = G("n")

m.x = g
m.u = h
k.z = f
k.p = f
k.q = i
k.r = m
f.s = m
g.x = f
g.q = n
h.z = i
h.x = m
h.v = g
i.t = n
i.w = n
n.y = m
n.x = m
n.o = g
n.r = g
n.z = k
n.s = f
assert g.q.z.r.u.v.x.txt == "f"