class A:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: E = None
        self.t: A = None
        self.txt = txt

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

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

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

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

c = A("c")
n = B("n")
e = C("e")
a = D("a")
d = E("d")
h = F("h")
g = C("g")

c.y = h
n.v = a
n.y = d
n.t = c
e.v = h
a.u = h
a.p = h
a.r = g
d.w = c
d.q = n
h.z = n
h.q = e
h.o = c
h.y = a
g.v = h
assert h.o.y.z.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: E = None
        self.t: A = None
        self.txt = txt

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

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

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

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

c = A("c")
n = B("n")
e = C("e")
a = D("a")
d = E("d")
h = F("h")
g = C("g")

c.y = h
n.v = a
n.y = d
n.t = c
e.v = h
a.u = h
a.p = h
a.r = g
d.w = c
d.q = n
h.z = n
h.q = e
h.o = c
h.y = a
g.v = h
assert h.o.y.z.y.q.txt == "n"