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

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

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

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

f = A("f")
k = B("k")
b = C("b")
e = D("e")
h = C("h")
d = D("d")
m = A("m")

f.y = d
f.o = k
k.w = d
b.v = h
b.u = h
b.s = m
e.q = f
e.t = h
h.v = b
h.u = b
h.s = f
d.q = m
d.t = b
m.y = d
m.o = k
assert k.w.q.y.q.o.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.o: B = None
        self.txt = txt

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

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

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

f = A("f")
k = B("k")
b = C("b")
e = D("e")
h = C("h")
d = D("d")
m = A("m")

f.y = d
f.o = k
k.w = d
b.v = h
b.u = h
b.s = m
e.q = f
e.t = h
h.v = b
h.u = b
h.s = f
d.q = m
d.t = b
m.y = d
m.o = k
assert k.w.q.y.q.o.w.q.txt == "m"