class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: C = None
        self.w: C = None
        self.x: G = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.v: B = None
        self.u: B = None
        self.txt = txt

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

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

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

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

h.w = f
c.s = h
c.u = j
c.w = j
c.x = e
j.y = k
j.o = k
j.w = e
f.o = k
f.v = c
f.u = c
k.w = e
k.q = c
m.t = f
m.w = j
m.v = k
e.t = h
e.q = m
assert h.w.o.q.x.q.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: C = None
        self.w: C = None
        self.x: G = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.v: B = None
        self.u: B = None
        self.txt = txt

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

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

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

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

h.w = f
c.s = h
c.u = j
c.w = j
c.x = e
j.y = k
j.o = k
j.w = e
f.o = k
f.v = c
f.u = c
k.w = e
k.q = c
m.t = f
m.w = j
m.v = k
e.t = h
e.q = m
assert h.w.o.q.x.q.v.w.txt == "e"