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

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

class C:
    def __init__(self, txt: str):
        self.w: F = None
        self.v: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.r: E = 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.y: A = None
        self.r: B = None
        self.txt = txt

j = A("j")
m = B("m")
k = C("k")
c = D("c")
f = E("f")
d = F("d")

j.z = k
j.p = k
m.t = d
k.w = d
k.v = c
c.y = f
c.r = f
f.z = m
d.y = j
d.r = m
assert m.t.r.t.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: F = None
        self.v: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.r: E = 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.y: A = None
        self.r: B = None
        self.txt = txt

j = A("j")
m = B("m")
k = C("k")
c = D("c")
f = E("f")
d = F("d")

j.z = k
j.p = k
m.t = d
k.w = d
k.v = c
c.y = f
c.r = f
f.z = m
d.y = j
d.r = m
assert m.t.r.t.r.t.r.txt == "m"