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

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

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

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

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

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

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

g = A("g")
d = B("d")
j = C("j")
a = D("a")
n = E("n")
c = F("c")
l = G("l")

g.x = j
d.z = a
d.x = g
j.v = l
j.z = g
a.y = d
a.r = g
n.w = j
n.r = l
n.s = c
c.y = l
l.q = c
assert j.v.q.y.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

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

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

g = A("g")
d = B("d")
j = C("j")
a = D("a")
n = E("n")
c = F("c")
l = G("l")

g.x = j
d.z = a
d.x = g
j.v = l
j.z = g
a.y = d
a.r = g
n.w = j
n.r = l
n.s = c
c.y = l
l.q = c
assert j.v.q.y.q.y.txt == "l"