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

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: A = None
        self.s: F = None
        self.txt = txt

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

h = A("h")
l = B("l")
f = C("f")
i = D("i")
k = E("k")
n = F("n")
c = C("c")

h.z = l
l.y = i
f.w = i
f.v = k
f.t = n
i.x = f
i.p = l
i.v = h
k.y = l
k.z = h
k.s = n
n.s = h
n.r = i
c.w = i
c.v = k
c.t = n
assert l.y.p.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: A = None
        self.s: F = None
        self.txt = txt

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

h = A("h")
l = B("l")
f = C("f")
i = D("i")
k = E("k")
n = F("n")
c = C("c")

h.z = l
l.y = i
f.w = i
f.v = k
f.t = n
i.x = f
i.p = l
i.v = h
k.y = l
k.z = h
k.s = n
n.s = h
n.r = i
c.w = i
c.v = k
c.t = n
assert l.y.p.y.v.txt == "h"