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

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.p: B = None
        self.w: A = None
        self.o: F = None
        self.s: F = None
        self.txt = txt

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

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.p: B = None
        self.w: A = None
        self.o: F = None
        self.s: F = None
        self.txt = txt

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

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

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

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