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

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

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

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

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

j.y = g
j.z = c
j.w = l
g.q = l
l.x = k
c.x = l
c.z = g
i.x = k
k.x = l
assert k.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: D = None
        self.w: C = None
        self.txt = txt

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

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

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

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

j.y = g
j.z = c
j.w = l
g.q = l
l.x = k
c.x = l
c.z = g
i.x = k
k.x = l
assert k.x.x.x.x.txt == "k"