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

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: C = None
        self.txt = txt

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

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

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

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

a = A("a")
k = B("k")
g = C("g")
c = D("c")
i = E("i")
e = F("e")

a.v = g
a.p = k
k.s = c
k.x = g
g.v = k
c.t = i
c.w = g
c.u = g
i.w = g
e.r = k
e.q = a
assert g.v.s.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: C = None
        self.txt = txt

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

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

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

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

a = A("a")
k = B("k")
g = C("g")
c = D("c")
i = E("i")
e = F("e")

a.v = g
a.p = k
k.s = c
k.x = g
g.v = k
c.t = i
c.w = g
c.u = g
i.w = g
e.r = k
e.q = a
assert g.v.s.t.w.txt == "g"