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

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.y: E = None
        self.s: G = None
        self.o: F = None
        self.w: G = None
        self.v: D = None
        self.x: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: G = None
        self.z: A = None
        self.u: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

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

f.v = h
f.u = c
f.q = c
e.r = h
e.y = h
e.s = m
e.w = m
e.x = m
e.o = l
e.v = d
c.q = m
c.u = m
c.z = f
d.p = e
h.w = e
l.z = c
l.w = e
l.r = d
m.s = h
m.o = h
m.r = h
m.x = l
m.y = c
m.t = f
m.q = f
assert d.p.v.p.r.w.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.u: C = None
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.y: E = None
        self.s: G = None
        self.o: F = None
        self.w: G = None
        self.v: D = None
        self.x: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: G = None
        self.z: A = None
        self.u: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

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

f.v = h
f.u = c
f.q = c
e.r = h
e.y = h
e.s = m
e.w = m
e.x = m
e.o = l
e.v = d
c.q = m
c.u = m
c.z = f
d.p = e
h.w = e
l.z = c
l.w = e
l.r = d
m.s = h
m.o = h
m.r = h
m.x = l
m.y = c
m.t = f
m.q = f
assert d.p.v.p.r.w.v.p.txt == "e"