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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: D = None
        self.z: C = None
        self.q: E = None
        self.y: C = None
        self.r: E = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.p: A = None
        self.t: E = None
        self.s: E = None
        self.txt = txt

k = A("k")
e = B("e")
l = C("l")
d = D("d")
b = E("b")
g = F("g")

k.r = e
e.p = l
e.z = l
e.y = l
e.x = d
e.q = b
e.r = b
l.y = b
l.z = e
l.r = e
d.q = l
d.r = e
d.p = e
d.z = k
d.s = k
b.o = k
g.p = k
g.t = b
g.s = b
assert d.s.r.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: D = None
        self.z: C = None
        self.q: E = None
        self.y: C = None
        self.r: E = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.p: A = None
        self.t: E = None
        self.s: E = None
        self.txt = txt

k = A("k")
e = B("e")
l = C("l")
d = D("d")
b = E("b")
g = F("g")

k.r = e
e.p = l
e.z = l
e.y = l
e.x = d
e.q = b
e.r = b
l.y = b
l.z = e
l.r = e
d.q = l
d.r = e
d.p = e
d.z = k
d.s = k
b.o = k
g.p = k
g.t = b
g.s = b
assert d.s.r.r.o.r.txt == "e"