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

class B:
    def __init__(self, txt: str):
        self.v: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: F = None
        self.t: B = None
        self.s: D = None
        self.o: B = None
        self.r: D = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.t: E = None
        self.p: A = None
        self.q: B = None
        self.o: A = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: C = None
        self.u: C = None
        self.q: F = None
        self.txt = txt

f = A("f")
k = B("k")
n = C("n")
c = D("c")
b = E("b")
g = F("g")
l = G("l")
m = E("m")
h = E("h")
e = G("e")

f.x = e
k.v = e
n.x = g
n.t = k
n.o = k
n.s = c
n.r = c
c.z = e
b.o = f
g.t = b
g.p = f
g.o = f
g.q = k
l.p = k
l.s = n
l.u = n
l.q = g
m.o = f
h.o = f
e.p = k
e.s = n
e.u = n
e.q = g
assert n.t.v.p.v.p.v.q.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: G = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: F = None
        self.t: B = None
        self.s: D = None
        self.o: B = None
        self.r: D = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.t: E = None
        self.p: A = None
        self.q: B = None
        self.o: A = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: C = None
        self.u: C = None
        self.q: F = None
        self.txt = txt

f = A("f")
k = B("k")
n = C("n")
c = D("c")
b = E("b")
g = F("g")
l = G("l")
m = E("m")
h = E("h")
e = G("e")

f.x = e
k.v = e
n.x = g
n.t = k
n.o = k
n.s = c
n.r = c
c.z = e
b.o = f
g.t = b
g.p = f
g.o = f
g.q = k
l.p = k
l.s = n
l.u = n
l.q = g
m.o = f
h.o = f
e.p = k
e.s = n
e.u = n
e.q = g
assert n.t.v.p.v.p.v.q.t.o.txt == "f"