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

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.t: D = None
        self.y: B = None
        self.w: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.r: C = None
        self.u: F = None
        self.txt = txt

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

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

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

n.o = d
n.q = d
n.y = d
d.q = i
d.u = i
d.z = i
l.z = h
l.w = h
l.t = f
l.y = d
f.y = l
f.w = n
h.o = f
h.r = l
h.u = c
c.y = d
c.s = i
c.q = h
i.x = h
i.z = d
assert c.y.u.z.q.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: B = None
        self.y: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.t: D = None
        self.y: B = None
        self.w: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.r: C = None
        self.u: F = None
        self.txt = txt

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

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

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

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