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

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

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

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

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

c.u = g
c.q = g
i.p = g
i.t = l
l.p = i
l.u = i
l.y = g
l.q = g
g.r = l
assert i.t.u.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.q: D = None
        self.txt = txt

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

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

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

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

c.u = g
c.q = g
i.p = g
i.t = l
l.p = i
l.u = i
l.y = g
l.q = g
g.r = l
assert i.t.u.p.r.txt == "l"