class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: E = None
        self.s: B = None
        self.txt = txt

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

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

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

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

e.u = m
f.y = m
f.o = n
f.q = e
k.q = n
k.v = f
d.w = n
d.s = f
n.q = d
m.z = k
m.v = f
c.v = f
c.x = m
assert f.o.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: E = None
        self.s: B = None
        self.txt = txt

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

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

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

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

e.u = m
f.y = m
f.o = n
f.q = e
k.q = n
k.v = f
d.w = n
d.s = f
n.q = d
m.z = k
m.v = f
c.v = f
c.x = m
assert f.o.q.w.q.txt == "d"