class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: A = None
        self.y: 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.y: B = None
        self.r: A = None
        self.t: B = None
        self.txt = txt

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

f = A("f")
c = B("c")
m = C("m")
i = D("i")
e = B("e")
a = A("a")
h = D("h")
b = B("b")

f.x = c
f.w = a
f.y = b
c.y = h
m.y = e
m.r = f
m.t = b
i.z = h
i.t = m
e.y = i
a.x = b
a.y = b
a.w = f
h.z = i
h.t = m
b.y = i
assert a.w.y.y.t.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: A = None
        self.y: 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.y: B = None
        self.r: A = None
        self.t: B = None
        self.txt = txt

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

f = A("f")
c = B("c")
m = C("m")
i = D("i")
e = B("e")
a = A("a")
h = D("h")
b = B("b")

f.x = c
f.w = a
f.y = b
c.y = h
m.y = e
m.r = f
m.t = b
i.z = h
i.t = m
e.y = i
a.x = b
a.y = b
a.w = f
h.z = i
h.t = m
b.y = i
assert a.w.y.y.t.r.y.txt == "b"