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

class B:
    def __init__(self, txt: str):
        self.u: F = None
        self.x: E = None
        self.r: F = None
        self.y: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.t: B = None
        self.r: A = None
        self.x: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: D = None
        self.s: E = None
        self.o: C = None
        self.p: C = None
        self.x: C = None
        self.q: D = None
        self.y: B = None
        self.txt = txt

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

d = A("d")
g = B("g")
i = C("i")
c = D("c")
f = E("f")
n = F("n")
l = G("l")

d.v = f
d.q = l
g.u = n
g.r = n
g.x = f
g.y = f
i.x = g
c.r = f
c.x = g
f.u = n
f.t = g
f.x = g
f.r = d
n.v = c
n.q = c
n.s = f
n.o = i
n.p = i
n.x = i
n.y = g
l.r = i
l.u = d
l.z = d
assert g.y.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.q: G = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: F = None
        self.x: E = None
        self.r: F = None
        self.y: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.t: B = None
        self.r: A = None
        self.x: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: D = None
        self.s: E = None
        self.o: C = None
        self.p: C = None
        self.x: C = None
        self.q: D = None
        self.y: B = None
        self.txt = txt

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

d = A("d")
g = B("g")
i = C("i")
c = D("c")
f = E("f")
n = F("n")
l = G("l")

d.v = f
d.q = l
g.u = n
g.r = n
g.x = f
g.y = f
i.x = g
c.r = f
c.x = g
f.u = n
f.t = g
f.x = g
f.r = d
n.v = c
n.q = c
n.s = f
n.o = i
n.p = i
n.x = i
n.y = g
l.r = i
l.u = d
l.z = d
assert g.y.r.v.txt == "f"