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

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

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

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

l = A("l")
f = B("f")
h = C("h")
c = D("c")
g = B("g")
a = C("a")
e = D("e")
d = A("d")

l.y = e
l.r = d
l.o = f
f.p = c
h.s = g
c.y = d
g.p = e
a.s = g
e.y = l
d.y = c
d.r = l
d.o = f
assert h.s.p.y.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.r: A = None
        self.o: B = None
        self.txt = txt

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

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

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

l = A("l")
f = B("f")
h = C("h")
c = D("c")
g = B("g")
a = C("a")
e = D("e")
d = A("d")

l.y = e
l.r = d
l.o = f
f.p = c
h.s = g
c.y = d
g.p = e
a.s = g
e.y = l
d.y = c
d.r = l
d.o = f
assert h.s.p.y.r.o.txt == "f"