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

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

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

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

j = A("j")
f = B("f")
a = C("a")
n = D("n")
d = B("d")
b = D("b")
k = A("k")
e = D("e")

j.z = k
f.v = e
f.s = e
f.w = a
f.r = d
a.y = d
a.w = f
n.w = a
n.p = k
d.v = n
d.s = n
d.w = a
d.r = f
b.w = a
b.p = k
k.z = j
e.w = a
e.p = k
assert f.s.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
a = C("a")
n = D("n")
d = B("d")
b = D("b")
k = A("k")
e = D("e")

j.z = k
f.v = e
f.s = e
f.w = a
f.r = d
a.y = d
a.w = f
n.w = a
n.p = k
d.v = n
d.s = n
d.w = a
d.r = f
b.w = a
b.p = k
k.z = j
e.w = a
e.p = k
assert f.s.w.w.txt == "f"