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

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: B = None
        self.z: G = None
        self.o: A = None
        self.w: A = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
h = C("h")
f = D("f")
d = E("d")
c = F("c")
j = G("j")

g.u = f
i.t = h
h.t = g
h.x = g
h.u = j
f.q = h
f.x = i
f.z = j
f.o = g
f.w = g
d.p = i
d.v = i
c.v = j
c.r = g
j.q = c
j.v = i
j.r = d
assert f.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: B = None
        self.z: G = None
        self.o: A = None
        self.w: A = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
h = C("h")
f = D("f")
d = E("d")
c = F("c")
j = G("j")

g.u = f
i.t = h
h.t = g
h.x = g
h.u = j
f.q = h
f.x = i
f.z = j
f.o = g
f.w = g
d.p = i
d.v = i
c.v = j
c.r = g
j.q = c
j.v = i
j.r = d
assert f.x.t.t.txt == "g"