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

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: E = 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.v: D = None
        self.o: B = None
        self.u: B = None
        self.txt = txt

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

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

f.x = m
f.z = c
g.y = d
j.w = d
j.q = f
j.o = n
j.u = m
m.p = j
m.v = n
n.w = j
d.v = m
d.o = a
d.u = a
c.v = f
c.z = f
c.x = j
c.o = j
c.r = n
a.y = d
assert c.x.u.p.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: G = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: E = 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.v: D = None
        self.o: B = None
        self.u: B = None
        self.txt = txt

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

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

f.x = m
f.z = c
g.y = d
j.w = d
j.q = f
j.o = n
j.u = m
m.p = j
m.v = n
n.w = j
d.v = m
d.o = a
d.u = a
c.v = f
c.z = f
c.x = j
c.o = j
c.r = n
a.y = d
assert c.x.u.p.q.z.txt == "c"