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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.o: C = None
        self.r: E = None
        self.y: A = None
        self.v: G = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: D = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.o: C = None
        self.r: E = None
        self.y: A = None
        self.v: G = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: D = None
        self.txt = txt

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

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