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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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