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

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

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

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

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

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

e = A("e")
m = B("m")
l = C("l")
a = D("a")
g = E("g")
n = F("n")

e.y = m
e.p = m
e.z = a
m.t = g
l.t = m
l.y = m
l.z = m
l.q = e
l.o = e
a.r = m
a.q = g
g.q = a
n.q = e
n.s = a
assert m.t.q.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: D = None
        self.p: B = None
        self.txt = txt

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

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

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

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

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

e = A("e")
m = B("m")
l = C("l")
a = D("a")
g = E("g")
n = F("n")

e.y = m
e.p = m
e.z = a
m.t = g
l.t = m
l.y = m
l.z = m
l.q = e
l.o = e
a.r = m
a.q = g
g.q = a
n.q = e
n.s = a
assert m.t.q.r.t.txt == "g"