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

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

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

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

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

l.w = j
f.w = k
f.r = k
f.z = b
e.o = k
e.x = j
j.r = b
j.x = d
k.o = e
k.x = j
b.w = k
b.r = e
b.z = f
d.w = j
assert b.w.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

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

l.w = j
f.w = k
f.r = k
f.z = b
e.o = k
e.x = j
j.r = b
j.x = d
k.o = e
k.x = j
b.w = k
b.r = e
b.z = f
d.w = j
assert b.w.o.o.o.txt == "e"