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

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

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

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

l = A("l")
f = B("f")
b = C("b")
j = D("j")
i = C("i")

l.w = f
l.y = b
l.r = b
l.p = i
f.z = i
f.t = i
f.p = j
b.z = j
j.t = f
i.z = j
assert i.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: C = None
        self.r: C = None
        self.p: C = None
        self.txt = txt

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

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

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

l = A("l")
f = B("f")
b = C("b")
j = D("j")
i = C("i")

l.w = f
l.y = b
l.r = b
l.p = i
f.z = i
f.t = i
f.p = j
b.z = j
j.t = f
i.z = j
assert i.z.t.z.txt == "i"