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

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

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

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

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

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

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

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

j.z = n
a.w = g
a.p = l
l.q = a
l.x = j
n.o = j
h.w = l
h.s = f
f.t = g
f.y = h
f.v = h
f.o = j
f.x = j
g.x = l
assert g.x.q.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

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

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

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

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

j.z = n
a.w = g
a.p = l
l.q = a
l.x = j
n.o = j
h.w = l
h.s = f
f.t = g
f.y = h
f.v = h
f.o = j
f.x = j
g.x = l
assert g.x.q.p.x.txt == "j"