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

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

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

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

f = A("f")
m = B("m")
g = C("g")
h = D("h")
e = C("e")
k = C("k")
i = A("i")
d = C("d")

f.y = m
f.u = m
f.r = i
m.u = h
g.q = h
g.u = h
g.y = m
h.u = e
h.x = f
h.s = f
e.q = h
e.u = h
e.y = m
k.q = h
k.u = h
k.y = m
i.y = m
i.u = m
i.r = f
d.q = h
d.u = h
d.y = m
assert h.s.y.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: B = None
        self.r: A = None
        self.txt = txt

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

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

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

f = A("f")
m = B("m")
g = C("g")
h = D("h")
e = C("e")
k = C("k")
i = A("i")
d = C("d")

f.y = m
f.u = m
f.r = i
m.u = h
g.q = h
g.u = h
g.y = m
h.u = e
h.x = f
h.s = f
e.q = h
e.u = h
e.y = m
k.q = h
k.u = h
k.y = m
i.y = m
i.u = m
i.r = f
d.q = h
d.u = h
d.y = m
assert h.s.y.u.s.txt == "f"