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

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

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

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

h = A("h")
j = B("j")
f = C("f")
m = D("m")
a = C("a")
k = C("k")
l = A("l")
g = D("g")

h.v = k
j.y = a
j.u = h
f.o = a
f.w = k
f.r = m
m.w = g
a.o = k
a.w = f
a.r = g
k.o = a
k.w = f
k.r = g
l.v = f
g.w = m
assert k.o.r.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

h = A("h")
j = B("j")
f = C("f")
m = D("m")
a = C("a")
k = C("k")
l = A("l")
g = D("g")

h.v = k
j.y = a
j.u = h
f.o = a
f.w = k
f.r = m
m.w = g
a.o = k
a.w = f
a.r = g
k.o = a
k.w = f
k.r = g
l.v = f
g.w = m
assert k.o.r.w.w.w.w.w.txt == "m"