class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: F = None
        self.o: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: A = None
        self.s: F = None
        self.r: E = None
        self.q: A = None
        self.u: D = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: E = None
        self.t: F = None
        self.txt = txt

k = A("k")
m = B("m")
f = C("f")
c = D("c")
b = E("b")
e = F("e")
d = G("d")
j = C("j")
n = E("n")
a = A("a")

k.x = f
k.z = e
k.o = m
m.q = a
f.q = j
c.q = b
b.z = c
b.u = c
b.x = a
b.s = e
b.r = n
b.q = k
e.u = c
e.t = n
e.x = d
e.v = j
e.z = a
d.r = f
d.q = n
d.t = e
j.q = f
n.z = c
n.u = c
n.x = a
n.q = a
n.s = e
n.r = b
a.x = f
a.z = e
a.o = m
assert k.x.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: F = None
        self.o: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: A = None
        self.s: F = None
        self.r: E = None
        self.q: A = None
        self.u: D = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: E = None
        self.t: F = None
        self.txt = txt

k = A("k")
m = B("m")
f = C("f")
c = D("c")
b = E("b")
e = F("e")
d = G("d")
j = C("j")
n = E("n")
a = A("a")

k.x = f
k.z = e
k.o = m
m.q = a
f.q = j
c.q = b
b.z = c
b.u = c
b.x = a
b.s = e
b.r = n
b.q = k
e.u = c
e.t = n
e.x = d
e.v = j
e.z = a
d.r = f
d.q = n
d.t = e
j.q = f
n.z = c
n.u = c
n.x = a
n.q = a
n.s = e
n.r = b
a.x = f
a.z = e
a.o = m
assert k.x.q.q.q.q.q.q.txt == "f"