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

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: D = None
        self.u: E = None
        self.w: F = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: F = None
        self.v: C = None
        self.txt = txt

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

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

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

g.q = n
g.t = e
c.y = e
c.q = h
c.u = l
c.w = j
e.x = g
e.r = h
h.y = j
l.z = e
l.v = e
l.u = j
j.r = n
n.s = h
n.o = e
assert g.t.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: G = None
        self.t: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: D = None
        self.u: E = None
        self.w: F = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: F = None
        self.v: C = None
        self.txt = txt

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

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

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

g.q = n
g.t = e
c.y = e
c.q = h
c.u = l
c.w = j
e.x = g
e.r = h
h.y = j
l.z = e
l.v = e
l.u = j
j.r = n
n.s = h
n.o = e
assert g.t.r.y.txt == "j"