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

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

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

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

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

i.v = g
j.q = g
l.u = i
l.z = i
g.x = j
g.t = i
g.p = i
assert l.z.v.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

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

i.v = g
j.q = g
l.u = i
l.z = i
g.x = j
g.t = i
g.p = i
assert l.z.v.x.q.txt == "g"