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

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

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

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

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

d.y = c
f.s = l
f.u = l
f.z = e
l.p = f
e.s = c
i.s = d
g.s = l
g.u = l
g.z = i
c.y = d
assert i.s.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

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

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

d.y = c
f.s = l
f.u = l
f.z = e
l.p = f
e.s = c
i.s = d
g.s = l
g.u = l
g.z = i
c.y = d
assert i.s.y.y.y.y.y.txt == "c"