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

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

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

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

f = A("f")
c = B("c")
e = C("e")
h = D("h")
b = C("b")
n = D("n")

f.w = h
f.s = c
c.y = h
e.w = b
e.y = c
e.x = h
h.w = b
b.w = e
b.y = c
b.x = n
n.w = e
assert f.w.w.y.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: B = None
        self.txt = txt

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

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

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

f = A("f")
c = B("c")
e = C("e")
h = D("h")
b = C("b")
n = D("n")

f.w = h
f.s = c
c.y = h
e.w = b
e.y = c
e.x = h
h.w = b
b.w = e
b.y = c
b.x = n
n.w = e
assert f.w.w.y.y.w.txt == "b"