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

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

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

class D:
    def __init__(self, txt: str):
        self.p: F = None
        self.q: E = None
        self.s: B = None
        self.z: G = None
        self.v: F = None
        self.y: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

g.o = h
h.q = k
h.y = n
h.p = g
h.w = c
h.r = j
f.z = k
n.p = k
n.v = k
n.q = d
n.s = c
n.z = m
n.y = f
d.w = n
k.s = f
m.q = k
m.s = n
c.q = k
c.y = n
c.p = g
c.w = h
c.r = f
j.z = k
assert d.w.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: F = None
        self.q: E = None
        self.s: B = None
        self.z: G = None
        self.v: F = None
        self.y: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

g.o = h
h.q = k
h.y = n
h.p = g
h.w = c
h.r = j
f.z = k
n.p = k
n.v = k
n.q = d
n.s = c
n.z = m
n.y = f
d.w = n
k.s = f
m.q = k
m.s = n
c.q = k
c.y = n
c.p = g
c.w = h
c.r = f
j.z = k
assert d.w.s.p.txt == "g"