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

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

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

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

k = A("k")
e = B("e")
b = C("b")
j = D("j")
i = D("i")
g = C("g")
n = A("n")
d = A("d")
c = C("c")
h = D("h")

k.r = b
e.z = n
e.w = h
e.v = d
e.y = j
b.w = k
j.r = h
j.p = d
j.z = c
i.r = j
i.p = n
i.z = b
g.w = k
n.r = g
d.r = g
c.w = k
h.r = i
h.p = n
h.z = c
assert g.w.r.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

k = A("k")
e = B("e")
b = C("b")
j = D("j")
i = D("i")
g = C("g")
n = A("n")
d = A("d")
c = C("c")
h = D("h")

k.r = b
e.z = n
e.w = h
e.v = d
e.y = j
b.w = k
j.r = h
j.p = d
j.z = c
i.r = j
i.p = n
i.z = b
g.w = k
n.r = g
d.r = g
c.w = k
h.r = i
h.p = n
h.z = c
assert g.w.r.w.r.w.txt == "k"