class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: F = None
        self.u: B = None
        self.s: E = None
        self.z: G = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: F = None
        self.o: C = None
        self.s: C = None
        self.q: A = None
        self.p: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: D = None
        self.y: E = None
        self.r: D = None
        self.q: D = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.r: F = None
        self.u: B = None
        self.s: E = None
        self.z: G = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: F = None
        self.o: C = None
        self.s: C = None
        self.q: A = None
        self.p: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: D = None
        self.y: E = None
        self.r: D = None
        self.q: D = None
        self.txt = txt

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

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

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