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

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

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

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

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

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

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

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

i.y = n
j.w = n
j.s = n
j.y = a
j.p = f
n.p = f
n.x = m
f.p = d
f.z = a
f.x = i
b.x = i
b.r = i
b.w = n
b.s = d
m.w = a
a.w = j
a.s = f
a.p = m
d.x = i
d.r = i
d.w = n
d.s = b
assert f.p.w.x.w.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

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

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

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

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

i.y = n
j.w = n
j.s = n
j.y = a
j.p = f
n.p = f
n.x = m
f.p = d
f.z = a
f.x = i
b.x = i
b.r = i
b.w = n
b.s = d
m.w = a
a.w = j
a.s = f
a.p = m
d.x = i
d.r = i
d.w = n
d.s = b
assert f.p.w.x.w.s.x.txt == "i"