class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: G = None
        self.o: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.t: A = None
        self.r: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: G = None
        self.v: G = None
        self.z: F = None
        self.t: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.s: G = None
        self.txt = txt

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

g = A("g")
d = B("d")
i = C("i")
n = D("n")
b = E("b")
c = F("c")
a = G("a")
m = F("m")

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

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.t: A = None
        self.r: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: G = None
        self.v: G = None
        self.z: F = None
        self.t: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.s: G = None
        self.txt = txt

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

g = A("g")
d = B("d")
i = C("i")
n = D("n")
b = E("b")
c = F("c")
a = G("a")
m = F("m")

g.s = n
g.x = a
g.o = b
d.p = n
i.z = b
i.t = g
i.r = n
n.y = a
n.v = a
n.z = m
n.t = d
b.q = g
b.v = g
c.s = a
a.v = b
m.s = a
assert c.s.v.v.x.v.txt == "b"