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

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

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

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

b = A("b")
k = B("k")
l = C("l")
h = D("h")
e = B("e")
i = D("i")
f = D("f")

b.y = k
k.v = e
k.r = e
k.w = l
k.y = b
l.s = b
h.r = f
e.v = k
e.r = k
e.w = l
e.y = b
i.r = h
f.r = h
assert e.w.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
l = C("l")
h = D("h")
e = B("e")
i = D("i")
f = D("f")

b.y = k
k.v = e
k.r = e
k.w = l
k.y = b
l.s = b
h.r = f
e.v = k
e.r = k
e.w = l
e.y = b
i.r = h
f.r = h
assert e.w.s.y.txt == "k"