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

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

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.z: D = None
        self.v: B = None
        self.t: A = None
        self.q: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

c.w = m
c.q = b
f.o = g
f.u = g
f.t = c
n.o = m
n.z = g
n.q = g
n.v = f
n.t = c
g.q = c
g.y = c
g.p = b
m.z = f
b.q = m
d.o = m
d.z = g
d.q = g
d.v = f
d.t = c
assert n.z.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.q: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.z: D = None
        self.v: B = None
        self.t: A = None
        self.q: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

c.w = m
c.q = b
f.o = g
f.u = g
f.t = c
n.o = m
n.z = g
n.q = g
n.v = f
n.t = c
g.q = c
g.y = c
g.p = b
m.z = f
b.q = m
d.o = m
d.z = g
d.q = g
d.v = f
d.t = c
assert n.z.p.q.txt == "m"