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

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

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

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

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

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

c = A("c")
a = B("a")
n = C("n")
k = D("k")
j = E("j")
d = F("d")

c.u = d
c.y = k
a.r = c
n.v = a
k.z = n
k.s = j
j.q = d
j.r = c
d.y = k
d.r = j
assert d.r.r.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.y: D = None
        self.txt = txt

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

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

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

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

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

c = A("c")
a = B("a")
n = C("n")
k = D("k")
j = E("j")
d = F("d")

c.u = d
c.y = k
a.r = c
n.v = a
k.z = n
k.s = j
j.q = d
j.r = c
d.y = k
d.r = j
assert d.r.r.u.y.txt == "k"