class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: E = None
        self.q: A = None
        self.v: E = None
        self.u: A = None
        self.txt = txt

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

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

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

c.v = h
k.r = c
k.u = h
k.t = d
k.s = n
n.p = k
h.w = n
h.y = a
h.v = a
h.q = c
h.u = c
a.x = d
a.t = n
d.y = n
d.r = a
assert n.p.t.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: E = None
        self.q: A = None
        self.v: E = None
        self.u: A = None
        self.txt = txt

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

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

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

c.v = h
k.r = c
k.u = h
k.t = d
k.s = n
n.p = k
h.w = n
h.y = a
h.v = a
h.q = c
h.u = c
a.x = d
a.t = n
d.y = n
d.r = a
assert n.p.t.y.p.txt == "k"