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

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

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

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

g = A("g")
i = B("i")
f = C("f")
b = D("b")
e = B("e")

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

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

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

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

g = A("g")
i = B("i")
f = C("f")
b = D("b")
e = B("e")

g.y = b
i.z = f
f.r = b
f.s = b
f.u = g
b.p = i
e.z = f
assert i.z.u.y.p.txt == "i"