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

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

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

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

f = A("f")
k = B("k")
n = C("n")
d = D("d")
h = A("h")
m = B("m")
l = C("l")

f.z = n
f.q = d
f.w = h
k.p = l
n.v = h
n.w = h
d.s = l
d.x = l
h.z = n
h.q = d
h.w = f
m.p = n
l.v = f
l.w = h
assert l.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: D = None
        self.w: A = None
        self.txt = txt

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

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

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

f = A("f")
k = B("k")
n = C("n")
d = D("d")
h = A("h")
m = B("m")
l = C("l")

f.z = n
f.q = d
f.w = h
k.p = l
n.v = h
n.w = h
d.s = l
d.x = l
h.z = n
h.q = d
h.w = f
m.p = n
l.v = f
l.w = h
assert l.w.w.w.txt == "h"