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

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

class C:
    def __init__(self, txt: str):
        self.w: F = None
        self.y: D = None
        self.u: A = None
        self.s: B = None
        self.x: B = None
        self.txt = txt

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

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

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

m = A("m")
e = B("e")
k = C("k")
g = D("g")
c = E("c")
f = F("f")

m.r = f
e.q = g
e.p = f
e.w = c
e.r = c
e.x = m
k.w = f
k.y = g
k.u = m
k.s = e
k.x = e
g.x = c
g.q = c
c.p = k
c.t = f
f.t = m
assert m.r.t.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: F = None
        self.y: D = None
        self.u: A = None
        self.s: B = None
        self.x: B = None
        self.txt = txt

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

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

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

m = A("m")
e = B("e")
k = C("k")
g = D("g")
c = E("c")
f = F("f")

m.r = f
e.q = g
e.p = f
e.w = c
e.r = c
e.x = m
k.w = f
k.y = g
k.u = m
k.s = e
k.x = e
g.x = c
g.q = c
c.p = k
c.t = f
f.t = m
assert m.r.t.r.t.txt == "m"