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

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

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

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

l = A("l")
a = B("a")
i = C("i")
g = D("g")

l.p = g
l.r = i
l.y = i
a.q = l
a.s = i
i.p = g
i.x = g
i.s = a
i.z = l
g.y = l
g.t = l
assert g.y.y.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: C = None
        self.y: C = None
        self.txt = txt

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

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

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

l = A("l")
a = B("a")
i = C("i")
g = D("g")

l.p = g
l.r = i
l.y = i
a.q = l
a.s = i
i.p = g
i.x = g
i.s = a
i.z = l
g.y = l
g.t = l
assert g.y.y.x.t.txt == "l"